diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-09-23 05:56:18 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-09-23 05:56:18 +0000 |
commit | 897cad3662024798463bc418bddaac801228da76 (patch) | |
tree | bdb615c5380cef3df6a35679f28fc9044287d449 | |
parent | 7776e2819833e302f654f7bfd34ff2c26b63460a (diff) | |
download | fetchmail-897cad3662024798463bc418bddaac801228da76.tar.gz fetchmail-897cad3662024798463bc418bddaac801228da76.tar.bz2 fetchmail-897cad3662024798463bc418bddaac801228da76.zip |
Better protection against buffer overruns.
svn path=/trunk/; revision=106
-rw-r--r-- | driver.c | 14 | ||||
-rw-r--r-- | fetchmail.c | 4 | ||||
-rw-r--r-- | fetchmail.h | 16 | ||||
-rw-r--r-- | imap.c | 6 | ||||
-rw-r--r-- | pop2.c | 10 | ||||
-rw-r--r-- | pop3.c | 10 |
6 files changed, 30 insertions, 30 deletions
@@ -66,7 +66,7 @@ struct method *proto; { int ok, len; int mboxfd; - char buf [POPBUFSIZE], host[HOSTLEN]; + char buf [POPBUFSIZE+1], host[HOSTLEN+1]; int socket; int first,number,count; @@ -250,7 +250,7 @@ int socket; const char *fmt; va_dcl { - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; va_list ap; if (protocol->tagged) @@ -288,7 +288,7 @@ const char *fmt; va_dcl { int ok; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; va_list ap; if (protocol->tagged) @@ -332,7 +332,7 @@ const char *host; { const char *from; int state = 0; - char mycopy[POPBUFSIZE]; + char mycopy[POPBUFSIZE+1]; if (strncmp("From: ", buf, 6) && strncmp("To: ", buf, 4) @@ -429,7 +429,7 @@ const char *host; static char *nxtaddr(hdr) char *hdr; { - static char *hp, *tp, address[POPBUFSIZE]; + static char *hp, *tp, address[POPBUFSIZE+1]; static state; if (hdr) @@ -562,8 +562,8 @@ char *pophost; int output; int rewrite; { - char buf [MSGBUFSIZE]; - char fromBuf[MSGBUFSIZE]; + char buf [MSGBUFSIZE+1]; + char fromBuf[MSGBUFSIZE+1]; char *bufp, *headers, *unixfrom, *fromhdr, *tohdr, *cchdr, *bcchdr; int n, oldlen; int inheaders; diff --git a/fetchmail.c b/fetchmail.c index 3b9dfc1c..f25ca98c 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -139,7 +139,7 @@ char **argv; tmpdir = "/tmp"; strcpy(tmpbuf, tmpdir); strcat(tmpbuf, "/poplock-"); - gethostname(tmpbuf + strlen(tmpbuf), HOSTLEN); + gethostname(tmpbuf + strlen(tmpbuf), HOSTLEN+1); if ((user = getenv("USER")) != (char *)NULL) { strcat(tmpbuf, "-"); @@ -339,7 +339,7 @@ struct hostrec *queryctl; for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++) { queryctl->protocol = autoprobe[i]; - if ((st = query_host(queryctl)) == PS_SUCCESS || st == PS_NOMAIL) + if ((st = query_host(queryctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL) break; } queryctl->protocol = P_AUTO; diff --git a/fetchmail.h b/fetchmail.h index 7bfb1921..17af19c5 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -50,15 +50,15 @@ struct hostrec { - char servername [HOSTLEN]; - char localname [USERNAMELEN]; - char remotename [USERNAMELEN]; - char password [PASSWORDLEN]; - char rpopid [PASSWORDLEN]; - char userfolder [FOLDERLEN]; + char servername [HOSTLEN+1]; + char localname [USERNAMELEN+1]; + char remotename [USERNAMELEN+1]; + char password [PASSWORDLEN+1]; + char rpopid [PASSWORDLEN+1]; + char userfolder [FOLDERLEN+1]; char remotefolder [FOLDERLEN]; - char smtphost[HOSTLEN]; - char mda [MDALEN]; + char smtphost[HOSTLEN+1]; + char mda [MDALEN+1]; int keep; int protocol; int fetchall; @@ -42,7 +42,7 @@ char *argbuf; int socket; { int ok; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; char *bufp; int n; @@ -134,7 +134,7 @@ int number; int limit; int *lenp; { - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; int num; if (limit) @@ -165,7 +165,7 @@ int socket; struct hostrec *queryctl; int number; { - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; if (SockGets(socket, buf,sizeof(buf)) < 0) return(PS_SOCKET); @@ -311,7 +311,7 @@ int socket; int POP2_stateGREET (socket) int socket; { - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; /* read the greeting from the server */ if (SockGets(socket, buf, sizeof(buf)) >= 0) { @@ -356,7 +356,7 @@ int POP2_stateNMBR (socket) int socket; { int number; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; /* read the NMBR (#ccc) message from the server */ if (SockGets(socket, buf, sizeof(buf)) >= 0) { @@ -405,7 +405,7 @@ int POP2_stateSIZE (socket) int socket; { int msgsize; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; /* read the SIZE message (=ccc) from the server */ if (SockGets(socket, buf, sizeof(buf)) >= 0) @@ -463,8 +463,8 @@ int mboxfd; int topipe; { int i,buflen,actsize; - char buf [MSGBUFSIZE]; - char frombuf [MSGBUFSIZE]; + char buf [MSGBUFSIZE+1]; + char frombuf [MSGBUFSIZE+1]; char savec; int msgTop; int needFrom; @@ -47,7 +47,7 @@ char *argbuf; int socket; { int ok; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; char *bufp; if (SockGets(socket, buf, sizeof(buf)) >= 0) { @@ -86,7 +86,7 @@ int socket; struct hostrec *queryctl; char *greeting; { - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; #if defined(HAVE_APOP_SUPPORT) /* build MD5 digest from greeting timestamp + password */ @@ -175,8 +175,8 @@ int *firstp; *firstp = 1; use_uidl = 0; if (!queryctl->fetchall) { - char buf [POPBUFSIZE]; - char id [IDLEN]; + char buf [POPBUFSIZE+1]; + char id [IDLEN+1]; int num; /* try LAST first */ @@ -282,7 +282,7 @@ int *msgcount; int socket; { int ok; - char buf [POPBUFSIZE]; + char buf [POPBUFSIZE+1]; int totalsize; SockPrintf(socket,"STAT\r\n"); |