*BSD News Article 33619


Return to BSD News archive

Xref: sserve comp.os.386bsd.questions:11931 comp.os.386bsd.development:2354 comp.os.386bsd.misc:2928
Newsgroups: comp.os.386bsd.questions,comp.os.386bsd.development,comp.os.386bsd.misc
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!uwm.edu!math.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!netcomsv!netcom.com!jmonroy
From: jmonroy@netcom.com (Jesus Monroy Jr)
Subject: Re: Why does FreeBSD 1.1.5 say gets() is unsafe?
Message-ID: <jmonroyCts1rL.96o@netcom.com>
Followup-To: comp.os.386bsd.questions,comp.os.386bsd.development,comp.os.386bsd.misc
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <30lrf3$2ii@acmez.gatech.edu> <311m2e$o33@agate.berkeley.edu> <jmonroyCtMGq2.IC6@netcom.com> <Ctn5yy.3I0@cs.vu.nl> <31cf70$3c@Starbase.NeoSoft.COM>
Date: Sat, 30 Jul 1994 23:40:33 GMT
Lines: 27

Peter da Silva (peter@Starbase.NeoSoft.COM) wrote:
: In article <Ctn5yy.3I0@cs.vu.nl>, Kees J. Bot <kjb@cs.vu.nl> wrote:
: >I don't have gets() in the C library on my system (Minix-386vm) at all.
: >Any gets(buf) call that I may find is immediately replaced by:

: >	result = fgets(buf, sizeof(buf), stdin);
: >	*strchr(buf, '\n') = 0;

: This can result in writing through the null pointer if reading from a zero
: length file and the buffer is uninitialized, or on any eof if the buffer is
: reinitialized, which will core dump on OSF/1 and generate enforcer hits on
: the Amiga.

: 	if(result = fgets(buf, sizeof(buf), stdin))
: 		*strchr(buf, '\n') = 0;
:
	boy!.... I ought to watch more carefully next time.
	In addition to referencing a "core dump" as a "good thing"
	now we are even saying that a compiler trick should be
	premier in coding examples.

	Next thing you know obfuscated will be the "in thing".
-- 
Jesus Monroy Jr                                          jmonroy@netcom.com
Zebra Research
/386BSD/device-drivers /fd /qic /clock /documentation
___________________________________________________________________________