Date: Sat, 1 Apr 2000 21:10:03 -0800 (PST) From: Anatoly Vorobey <mellon@pobox.com> To: freebsd-bugs@FreeBSD.org Subject: bin/12242 : segmentation fault running /usr/bin/fmt Message-ID: <200004020510.VAA60362@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/12242; it has been noted by GNATS.
From: Anatoly Vorobey <mellon@pobox.com>
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" <dzerkel@columbus.rr.com>
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004020510.VAA60362>
