dmc

dynamic mail client
git clone git://git.suckless.org/dmc
Log | Files | Refs | README | LICENSE

commit 887cd0bd20d3ff7d27beed34cc9f61a6081dd23b
parent 47cc67322d823adaf4cd2089253ef3d5c0afbb6a
Author: pancake@localhost.localdomain <unknown>
Date:   Mon,  2 Nov 2009 00:18:57 +0100

* Some fixes in the imap4 reply parser
* Fix sock_read length in sock.c
Diffstat:
imap4.c | 18++++++++++++------
sock.c | 4++--
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/imap4.c b/imap4.c @@ -38,7 +38,7 @@ reread: str++; *str = 0; goto reread; - } else *p=0; + } else *p = 0; } } else { p = strchr(str, '"'); @@ -64,21 +64,27 @@ static int waitreply() { word[0] = result[0] = '\0'; while(lock || sock_ready()) { lock = 0; - if (sock_read (word, 2024) <1) + if (sock_read (word, 4095) <1) break; if (line++ == 0) { - ptr = strchr(word, ' '); + ptr = strchr (word, ' '); if (ptr) { - if (!memcmp(ptr+1, "OK", 2)) + if (!memcmp (ptr+1, "OK", 2)) reply = 1; else - if (!memcmp(ptr+1, "NO", 2)) + if (!memcmp (ptr+1, "NO", 2)) reply = 0; else // TODO: Do 'BAD' should be -1 ? - if (!memcmp(ptr+1, "BAD", 3)) + if (!memcmp (ptr+1, "BAD", 3)) reply = 0; + strcpy (word, ptr); } + ptr = strchr(word, '\n'); + if (ptr) + *ptr=0; snprintf (result, 254, "### %s %d \"%s\"\n", cmd, reply, word); + if (ptr) + *ptr='\n'; } write (2, word, strlen (word)); } diff --git a/sock.c b/sock.c @@ -100,10 +100,10 @@ int sock_read (char *buf, int len) { int ret; #if HAVE_SSL if (ssl) - ret = SSL_read (sfd, buf, 1024); + ret = SSL_read (sfd, buf, len); else #endif - ret = read (fd, buf, 1024); + ret = read (fd, buf, len); if (ret>0) buf[ret] = '\0'; return ret;