This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] wordexp resource cleanup


On 2012-08-20 12:17, Peter Rosin wrote:
> On 2012-08-20 00:00, Peter Rosin wrote:
>> While looking up how wordexp worked I noticed that the resource handling
>> in the implementation was "somewhat lacking". So here's a follow-up to
>> take care of a few corner cases. (Not even compile-tested as I don't
>> know how to set that up without reading up on the subject, but you
>> wouldn't trust a newcomer anyway, right?)
>>
>> 	* libc/posix/wordexp.c (wordexp): Free all file descriptors
>> 	and make sure the child is reaped in case of failure. Remove
>> 	dead code while at it.
>>
> 
> Whoops! There were more bugs in that function, so here's an update. This
> one has actually been tested and works AFAICT.
> 
> 	* libc/posix/wordexp.c (wordexp): Allocate enough storage for
> 	all returned words. Handle expanded words longer than 500 bytes.
> 	Return WRDE_NOSPACE on resource allocation failure, and cleanup
> 	leftover resources for that case.

Whoops, that's a misleading ChangeLog entry. The first part of it
referred to fixing a bug that I had introduced myself when sanitizing
the realloc calls. So, a better ChangeLog would be:

	* libc/posix/wordexp.c (wordexp): Handle expanded words longer
	than 500 bytes.	Return WRDE_NOSPACE on resource allocation
	failure. Cleanup leftover resources when failing.

Sorry for the noise.

Cheers,
Peter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]