aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-09-23 05:56:18 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-09-23 05:56:18 +0000
commit897cad3662024798463bc418bddaac801228da76 (patch)
treebdb615c5380cef3df6a35679f28fc9044287d449
parent7776e2819833e302f654f7bfd34ff2c26b63460a (diff)
downloadfetchmail-897cad3662024798463bc418bddaac801228da76.tar.gz
fetchmail-897cad3662024798463bc418bddaac801228da76.tar.bz2
fetchmail-897cad3662024798463bc418bddaac801228da76.zip
Better protection against buffer overruns.
svn path=/trunk/; revision=106
-rw-r--r--driver.c14
-rw-r--r--fetchmail.c4
-rw-r--r--fetchmail.h16
-rw-r--r--imap.c6
-rw-r--r--pop2.c10
-rw-r--r--pop3.c10
6 files changed, 30 insertions, 30 deletions
diff --git a/driver.c b/driver.c
index a707d1da..b66a446f 100644
--- a/driver.c
+++ b/driver.c
@@ -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;
diff --git a/imap.c b/imap.c
index fa1e9551..06312d02 100644
--- a/imap.c
+++ b/imap.c
@@ -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);
diff --git a/pop2.c b/pop2.c
index 26bc1ea9..5b27e918 100644
--- a/pop2.c
+++ b/pop2.c
@@ -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;
diff --git a/pop3.c b/pop3.c
index 379d3873..4ea41660 100644
--- a/pop3.c
+++ b/pop3.c
@@ -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");