*BSD News Article 33558


Return to BSD News archive

Xref: sserve comp.os.386bsd.questions:11958 comp.os.386bsd.development:2359 comp.os.386bsd.misc:2954
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!swrinde!news.uh.edu!uuneo.neosoft.com!Starbase.NeoSoft.COM!nobody
From: peter@Starbase.NeoSoft.COM (Peter da Silva)
Newsgroups: comp.os.386bsd.questions,comp.os.386bsd.development,comp.os.386bsd.misc
Subject: Re: Why does FreeBSD 1.1.5 say gets() is unsafe?
Date: 31 Jul 1994 14:47:37 -0500
Organization: NeoSoft Internet Services   +1 713 684 5969
Lines: 25
Message-ID: <31gv4p$gq1@Starbase.NeoSoft.COM>
References: <30lrf3$2ii@acmez.gatech.edu> <Ctn5yy.3I0@cs.vu.nl> <31cf70$3c@Starbase.NeoSoft.COM> <jmonroyCts1rL.96o@netcom.com>
NNTP-Posting-Host: starbase.neosoft.com

In article <jmonroyCts1rL.96o@netcom.com>,
Jesus Monroy Jr <jmonroy@netcom.com> wrote:
>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.

I beg your pardon. Could you translate this into english? I can't even tell
if you're flaming me or Kees.