diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-09-23 04:07:26 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-09-23 04:07:26 +0000 |
commit | ff0ca8acbc3b62ae1fdace42bffebb93178a0b3d (patch) | |
tree | 34925d9c2995282543bbf0ee1e5e1e7e88d34739 /usr.bin/mail | |
parent | 393333febcecdc8049bd3c7c6f9aac75c3563226 (diff) | |
download | FreeBSD-src-ff0ca8acbc3b62ae1fdace42bffebb93178a0b3d.zip FreeBSD-src-ff0ca8acbc3b62ae1fdace42bffebb93178a0b3d.tar.gz |
Don't add space after comma unless there was already one (prevents a
rare overflow). Optimize loop slightly. Don't exit if realloc can't
shrink a buffer (just continue and use the larger buffer).
Obtained from: OpenBSD
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/mail')
-rw-r--r-- | usr.bin/mail/aux.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index 401399a..d8c32b3 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -494,9 +494,9 @@ skin(name) *cp2++ = ' '; } *cp2++ = c; - if (c == ',' && !gotlt) { + if (c == ',' && *cp == ' ' && !gotlt) { *cp2++ = ' '; - for (; *cp == ' '; cp++) + while (*++cp == ' ') ; lastsp = 0; bufend = cp2; @@ -505,8 +505,8 @@ skin(name) } *cp2 = '\0'; - if ((nbuf = realloc(nbuf, strlen(nbuf) + 1)) == NULL) - err(1, "Out of memory"); + if ((cp = realloc(nbuf, strlen(nbuf) + 1)) != NULL) + nbuf = cp; return (nbuf); } |