--- imap.c.old Thu Jul 17 13:03:20 2003 +++ imap.c Sun Aug 3 13:42:57 2003 @@ -12,6 +12,7 @@ #if defined(STDC_HEADERS) #include #include +#include #endif #include "fetchmail.h" #include "socket.h" @@ -964,8 +965,12 @@ * it to be present, but at least one IMAP server (Novell GroupWise) * botches this. */ - if ((cp = strchr(buf, '{'))) - *lenp = atoi(cp + 1); + if ((cp = strchr(buf, '{'))) { + errno = 0; + *lenp = (int)strtol(cp + 1, (char **)NULL, 10); + if (errno == ERANGE && (*lenp == LONG_MAX || *lenp == LONG_MIN)) + *lenp = -1; /* length is too big/small for us to handle */ + } else *lenp = -1; /* missing length part in FETCH reponse */