unstrip: Stop using strndupa.
authorÉrico Rolim <erico.erc@gmail.com>
Tue, 27 Oct 2020 19:19:58 +0000 (16:19 -0300)
committerMark Wielaard <mark@klomp.org>
Tue, 27 Oct 2020 21:49:33 +0000 (22:49 +0100)
commite7e4c92650892cf67210be5ea89ffba967427cbf
tree4913d8190948ed53bca2472f8a1629a8c74f2efb
parent747a84b60e672cd7dedfb5f618ddd44770aada8e
unstrip: Stop using strndupa.

This functon has inherent safety issues, since a long enough path can
lead to memory clobbering. Due to the recursive nature of
make_directories(), multiple calls could also stack overflow. Instead,
the string can be allocated in the heap.

As a bonus, this improves musl compatibility, since musl doesn't include
the strndupa macro for now.

Also add braces around while loop.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
src/ChangeLog
src/unstrip.c