diff options
author | jlemon <jlemon@FreeBSD.org> | 1997-08-21 03:41:41 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 1997-08-21 03:41:41 +0000 |
commit | 5d3c68aeda6b25c847b3ad8a14bb11a9d77328aa (patch) | |
tree | abc236a20daf5cd637d99387086b79326490ebd9 /usr.bin/fmt/fmt.c | |
parent | 14785b595820705698dbf4472ed806d9c2fa536c (diff) | |
download | FreeBSD-src-5d3c68aeda6b25c847b3ad8a14bb11a9d77328aa.zip FreeBSD-src-5d3c68aeda6b25c847b3ad8a14bb11a9d77328aa.tar.gz |
Pre-allocate buffer to avoid core dump in corner cases.
PR: 2968
Submitted by: Gareth McCaughan <gjm11@dpmms.cam.ac.uk>
Diffstat (limited to 'usr.bin/fmt/fmt.c')
-rw-r--r-- | usr.bin/fmt/fmt.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/fmt/fmt.c b/usr.bin/fmt/fmt.c index 3c85550..fc27f65 100644 --- a/usr.bin/fmt/fmt.c +++ b/usr.bin/fmt/fmt.c @@ -42,7 +42,7 @@ static char copyright[] = static char sccsid[] = "@(#)fmt.c 8.1 (Berkeley) 7/20/93"; #else static const char rcsid[] = - "$Id$"; + "$Id: fmt.c,v 1.9 1997/07/03 07:19:46 charnier Exp $"; #endif #endif /* not lint */ @@ -162,7 +162,11 @@ fmt(fi) register char *cp, *cp2, cc; register int c, col; #define CHUNKSIZE 1024 - static int lbufsize = 0, cbufsize = 0; + static int lbufsize = 0, cbufsize = CHUNKSIZE; + + canonb = malloc(CHUNKSIZE); + if (canonb == 0) + abort(); if (center) { linebuf = malloc(BUFSIZ); |