From 5c09cbae3e433ed47a60ef02f3146926ac915094 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 27 Nov 1996 16:31:23 +0000 Subject: Avoid malloc overrun core-dump. svn path=/trunk/; revision=574 --- pop3.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pop3.c') diff --git a/pop3.c b/pop3.c index 79260f16..f2e46236 100644 --- a/pop3.c +++ b/pop3.c @@ -80,14 +80,15 @@ int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) /* find end of timestamp */ for (end = start; *end != 0 && *end != '>'; end++) continue; - if (*end == 0 || (end - start - 1) == 1) { + if (*end == 0 || end == start + 1) { fprintf(stderr,"Timestamp syntax error in greeting\n"); return(PS_AUTHFAIL); } + else + *++end = '\0'; /* copy timestamp and password into digestion buffer */ - msg = (char *)xmalloc((end-start-1) + strlen(ctl->password) + 1); - *(++end) = 0; + msg = (char *)xmalloc((end-start+1) + strlen(ctl->password) + 1); strcpy(msg,start); strcat(msg,ctl->password); -- cgit v1.2.3