Subject: Re: chmod patch
To: None <tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@tac.gw.com>
List: tech-userlevel
Date: 05/17/2005 15:13:20
In article <20050517195328.GB468@anarion>,
Liam J. Foy <liamfoy@sepulcrum.org> wrote:
>On Tue(17)/May/05 - , Christos Zoulas wrote:
>> In article <20050517183626.GA468@anarion>,
>> Liam J. Foy <liamfoy@sepulcrum.org> wrote:
>> >Hey,
>> >
>> >	Could you guys look at the following patch:
>> >
>> >
>> >- setmode(3) can return NULL due to malloc failing. However,
>> >  if malloc does fail an incorrect error message would be 
>> >  printed. You can resolve this by checking errno.
>> 
>> Actually someone will need to fix the source for setmode in order
>> for your patch to work. There are other calls that can set errno
>> (strtol() for example), so your patch is incorrect. You should
>> file a PR about fixing error checking and documentation in setmode.
>> 
>> christos
>
>I think you may be wrong here:
>	[snip]
>	if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL)
>		return (NULL);
>	saveset = set;
>	endset = set + (setlen - 2);
>	[snip]
>
>As you can see, it will return before we hit anything else to set errno.

Let's say malloc worked, and then strtol() failed and set errno. How
will you tell the difference?

Or you did:

	close(-1);
	setmode("");

That would not even call malloc...


christos