bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vasnprintf: fix potential use after free


From: Pádraig Brady
Subject: Re: [PATCH] vasnprintf: fix potential use after free
Date: Mon, 08 Dec 2014 10:17:55 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 08/12/14 02:29, Paul Eggert wrote:
> Pádraig Brady wrote:
>> BTW if free() may reset errno on some platforms then it's
>> probably worth augmenting the gnulib free() wrapper
>> to restore errno if needed,
> 
> The documented GNU behavior for 'free' allows 'free' to set errno, right?  So 
> why should the corresponding gnulib wrapper guarantee behavior above and 
> beyond 
> what GNU implements?
> 
> It might make sense to have a variant of 'free' that preserves errno, but we 
> should probably give the variant a different name.  'noerr_free', say.
> 

Well gnu docs never mention errno wrt free() so I suppose
it's therefore possible to be set to anything.
I did check GNU,{free,net,open}bsd,solaris and none touch
the errno for valid, NULL, or invalid pointers.
However I suppose there are certain edge cases where the
errno can be set. For example see the discussion at:
http://lists.freebsd.org/pipermail/freebsd-arch/2012-June/012669.html

Moreover since it's not practical to test for those cases
at configure time, the POSIX note previously referenced in this thread
is not possible to take advantage of portably.

Hence I pushed the attached to address this.

thanks,
Pádraig.

Attachment: vasnprintf-free-errno.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]