[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-mailutils] imap4d --foreground and DIGEST-MD5 buglet
From: |
Sergey Poznyakoff |
Subject: |
Re: [bug-mailutils] imap4d --foreground and DIGEST-MD5 buglet |
Date: |
Thu, 24 Sep 2009 17:20:37 +0300 |
Simon Josefsson <address@hidden> ha escrit:
> if (len == 0)
> {
> imap4d_bye (ERR_NO_IFILE);
> /*FIXME rc = ECONNABORTED;*/
> }
>
> This seems wrong -- sometimes (as in the example above) the expected
> data from the client can be zero-size.
Actually, that was because mu_stream_sequential_readline is expected
to read at least one byte, i.e. '\n'. If it returns 0 bytes, it
means it hit EOF. But the test should definitely go before calling
util_trim_nl, which further modifies len. So, I'd rather propose
this:
diff --git a/imap4d/util.c b/imap4d/util.c
index 8350de0..076d524 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -1375,6 +1375,12 @@ imap4d_getline (char **pbuf, size_t *psize, size_t
*pnbytes)
if (rc == 0)
{
char *s = *pbuf;
+
+ if (len == 0)
+ {
+ imap4d_bye (ERR_NO_IFILE);
+ /*FIXME rc = ECONNABORTED;*/
+ }
len = util_trim_nl (s, len);
if (imap4d_transcript)
{
@@ -1383,11 +1389,6 @@ imap4d_getline (char **pbuf, size_t *psize, size_t
*pnbytes)
else
mu_diag_output (MU_DIAG_DEBUG, "got EOF");
}
- if (len == 0)
- {
- imap4d_bye (ERR_NO_IFILE);
- /*FIXME rc = ECONNABORTED;*/
- }
if (pnbytes)
*pnbytes = len;
}
Can you test if it works for you?
Regards,
Sergey