From owner-freebsd-bugs Sat Apr 1 21:10: 6 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 3616937B5BD for ; Sat, 1 Apr 2000 21:10:04 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id VAA60362; Sat, 1 Apr 2000 21:10:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Date: Sat, 1 Apr 2000 21:10:03 -0800 (PST) Message-Id: <200004020510.VAA60362@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Anatoly Vorobey Subject: bin/12242 : segmentation fault running /usr/bin/fmt Reply-To: Anatoly Vorobey Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/12242; it has been noted by GNATS. From: Anatoly Vorobey To: dzerkel@columbus.rr.com, freebsd-gnats-submit@freebsd.org, grg@isabase.philol.msu.ru Cc: Subject: bin/12242 : segmentation fault running /usr/bin/fmt Date: Sun, 2 Apr 2000 07:05:22 +0200 > From: "Danny J. Zerkel" > Subject: Re: bin/12242: segmentation fault running /usr/bin/fmt > Date: Sat, 07 Aug 1999 23:05:51 -0400 > > Doing math on null pointers, sounds bad to me... This only was a > problem if the first line was longer than the default buffer size of > 1024. Of course, fmt does nothing to this file since it is only one > line and starts with '.'. This patch will at least keep it from dumping > core. > > --- /usr/src/usr.bin/fmt/fmt.c.orig Tue Sep 30 15:42:05 1997 > +++ /usr/src/usr.bin/fmt/fmt.c Sat Aug 7 22:40:31 1999 > @@ -450,7 +450,8 @@ > outbuf = realloc(outbuf, outbuf_size); > if (outbuf == 0) > abort(); > - outp += outbuf-old_outbuf; > + if (outp != NOSTR) > + outp += outbuf-old_outbuf; This will work, but isn't standard C (outbuf-old_outbuf is not good). Perhaps the following is better. Maybe someone could review/commit this? I've verified this solves the problem. --- fmt.c.orig Sat Aug 28 01:01:18 1999 +++ fmt.c Sun Apr 2 07:06:04 2000 @@ -450,7 +450,8 @@ outbuf = realloc(outbuf, outbuf_size); if (outbuf == 0) abort(); - outp += outbuf-old_outbuf; + if (outp != NOSTR) + outp = outbuf + (outp - old_outbuf); } -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message