From 3c4ab481e9cfe604f283f7173405fc27ae91b226 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 19 Oct 1996 14:17:06 +0000 Subject: Better octet-message parsing. svn path=/trunk/; revision=351 --- NEWS | 2 ++ pop3.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 734d564f..15451e45 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,8 @@ bugs -- * Rewrite "To: jrh (J. Random Hacker)" correctly. +* Find "nnn octets" anywhere on a POP3 server's RETR response line. + fetchmail-1.8 (Fri Oct 11 15:08:10 EDT 1996): features -- diff --git a/pop3.c b/pop3.c index bbf6e1ac..466926cd 100644 --- a/pop3.c +++ b/pop3.c @@ -6,6 +6,7 @@ #include #include +#include #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); } -- cgit v1.2.3