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

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]