diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-09-12 18:16:26 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-09-12 18:16:26 +0000 |
commit | c4f89823b2fde1e12583f95548d47c1417f9e998 (patch) | |
tree | be8253e3a332a8a9a34bf8b72396742241224d6d /smtp.c | |
parent | ffaee92b2a0699ed5f638224bc69600cb523b906 (diff) | |
download | fetchmail-c4f89823b2fde1e12583f95548d47c1417f9e998.tar.gz fetchmail-c4f89823b2fde1e12583f95548d47c1417f9e998.tar.bz2 fetchmail-c4f89823b2fde1e12583f95548d47c1417f9e998.zip |
Prevent buffer overflow.
svn path=/trunk/; revision=91
Diffstat (limited to 'smtp.c')
-rw-r--r-- | smtp.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -34,7 +34,7 @@ int SMTP_helo(int socket,char *host) { int ok; - char buf[SMTPBUFSIZE]; + char buf[SMTPBUFSIZE+1]; sprintf(buf,"HELO %s",host); SockPuts(socket, buf); @@ -61,7 +61,7 @@ int SMTP_helo(int socket,char *host) *********************************************************************/ int SMTP_from(int socket, char *from) { - char buf[SMTPBUFSIZE]; /* it's as good as size as any... */ + char buf[SMTPBUFSIZE+1]; /* it's as good as size as any... */ int ok; SockPrintf(socket, "MAIL FROM: %s\n", from); if (outlevel == O_VERBOSE) @@ -86,7 +86,7 @@ int SMTP_from(int socket, char *from) *********************************************************************/ int SMTP_rcpt(int socket,char *to) { - char buf[SMTPBUFSIZE]; /* it's as good as size as any... */ + char buf[SMTPBUFSIZE+1]; /* it's as good as size as any... */ int ok; SockPrintf(socket, "RCPT TO: %s\n", to); @@ -167,12 +167,10 @@ static int SMTP_check(int socket,char *argbuf) int ok; char buf[SMTPBUFSIZE]; - if ((ok = SMTP_Gets(socket, buf, sizeof(buf))) > 0) { + if ((ok = SMTP_Gets(socket, buf, sizeof(buf)-1)) > 0) { + buf[ok] = '\0'; if (outlevel == O_VERBOSE) - { - buf[ok] = '\0'; fprintf(stderr, "SMTP< %s", buf); - } if (argbuf) strcpy(argbuf,buf); if (buf[0] == '1' || buf[0] == '2' || buf[0] == '3') @@ -195,7 +193,7 @@ static int SMTP_check(int socket,char *argbuf) int SMTP_ok(int socket,char *argbuf) { int ok; - char buf[SMTPBUFSIZE]; + char buf[SMTPBUFSIZE+1]; /* I can tell that the SMTP server connection is ok if I can read a status message that starts with "1xx" ,"2xx" or "3xx". |