aboutsummaryrefslogtreecommitdiffstats
path: root/pop3.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-19 14:17:06 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-19 14:17:06 +0000
commit3c4ab481e9cfe604f283f7173405fc27ae91b226 (patch)
treec943ac760ba1b41c1dfb4a6d2d42e1f19bfdba20 /pop3.c
parent00fa03c8553785f9b123a8552d2b59266b418e2c (diff)
downloadfetchmail-3c4ab481e9cfe604f283f7173405fc27ae91b226.tar.gz
fetchmail-3c4ab481e9cfe604f283f7173405fc27ae91b226.tar.bz2
fetchmail-3c4ab481e9cfe604f283f7173405fc27ae91b226.zip
Better octet-message parsing.
svn path=/trunk/; revision=351
Diffstat (limited to 'pop3.c')
-rw-r--r--pop3.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pop3.c b/pop3.c
index bbf6e1ac..466926cd 100644
--- a/pop3.c
+++ b/pop3.c
@@ -6,6 +6,7 @@
#include <config.h>
#include <stdio.h>
+#include <string.h>
#include "socket.h"
#include "fetchmail.h"
@@ -191,12 +192,20 @@ int number;
int *lenp;
{
int ok;
- char buf [POPBUFSIZE+1];
+ char buf [POPBUFSIZE+1], *cp;
gen_send(socket, "RETR %d", number);
if ((ok = pop3_ok(socket, buf)) != 0)
return(ok);
- *lenp = atoi(buf);
+ /* look for "nnn octets" -- there may or may not be preceding cruft */
+ if ((cp = strstr(buf, " octets")) == (char *)NULL)
+ *lenp = 0;
+ else
+ {
+ while (isdigit(*--cp))
+ continue;
+ *lenp = atoi(++cp);
+ }
return(0);
}