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

Re: [libvirt] [PATCH] build: avoid unsafe functions in libgen.h



On 04/25/2013 02:41 PM, Laine Stump wrote:
> On 04/25/2013 04:30 PM, Eric Blake wrote:
>> POSIX says that both basename() and dirname() may return static
>> storage (aka they are not thread-safe); and that they may but
>> not must modify their input argument.  Furthermore, <libgen.h>
>> is not available on all platforms.  For these reasons, you should
>> never use these functions in a multi-threaded library.
>>
>> Gnulib instead recommends a way to avoid the portability nightmare:
>> gnulib's "dirname.h" provides useful counterparts.  The obvious
>> dir_name() and base_name() are GPL (because they malloc(), but call
>> exit() on failure) so we can't use them; but the LGPL variants
>> mdir_name() (malloc's or returns NULL) and last_component (always
>> points into the incoming string without modifying it, differing
>> from basename semantics only on corner cases like the empty string
>> that we shouldn't be hitting in the first place) are already in use
>> in libvirt.  This finishes the swap over to the safe functions.
>>

> 
> ACK. Thanks!

Now pushed.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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