delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/19/18:10:22

Date: Thu, 19 Jun 1997 14:59:22 -0700 (PDT)
Message-Id: <199706192159.OAA27333@adit.ap.net>
Mime-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Possible misbehavior of write
Cc: djgpp AT delorie DOT com

At 09:17  6/18/1997 +0300, eliz wrote:
>
>On Tue, 17 Jun 1997, Nate Eldredge wrote:
>
>> Is there a "correct" thing for write() to do when passed a null buffer? This
>> code:
>> 
>> write(fd,NULL,count);
>> 
>> ...assuming reasonable values for fd and count, under Linux returns -1 and
>> sets errno to EFAULT ("Bad address"). Under djgpp, however, it sends a
>> SIGSEGV. Is this correct? What does POSIX / ANSI have to say?
>
>It is generally preferred to have functions return EFAULT instead of
>crashing.  It's just that doing this test in each and every library
>function would really slow down the programs.  I suggest you submit
>the necessary patches anyhow.

Egad! I had a look at the sources and it seems it would require changing
alomst every function that takes a pointer argument. Plus, is it to check
just for NULL's, or decide whether it's a valid address some other way?
Maybe SIGSEGV isn't such a bad way to deal with it after all :-)

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019