segfault bb_make_directory + dirname with musl

Guillermo Rodriguez Garcia guille.rodriguez at gmail.com
Fri Dec 2 07:51:47 UTC 2016


2016-12-02 8:48 GMT+01:00 Guillermo Rodriguez Garcia
<guille.rodriguez at gmail.com>:
> 2016-12-01 21:13 GMT+01:00 Daniel Sabogal <dsabogalcc at gmail.com>:
>> On Wed, Nov 30, 2016 at 5:52 PM, Denys Vlasenko
>> <vda.linux at googlemail.com> wrote:
[...]
>>
>> This does prevent the segfault, but I'm not sure if depending on being able to
>> modify the result of dirname() is reliable.

(sorry for the previous empty mail)

I don't think it is reliable. The manpage for dirname says (emphasis mine):

       These  functions  may  return  pointers  to statically allocated memory
       which may be overwritten by subsequent calls.  Alternatively, they  may
       return  a  pointer to some part of path, so that *the string referred to
       by path should not be modified or freed* until the pointer  returned  by
       the function is no longer required.

Best,

Guillermo Rodriguez Garcia
guille.rodriguez at gmail.com


More information about the busybox mailing list