[Rpm-maint] The usage of basename()

Thierry Vignaud thierry.vignaud at gmail.com
Sun Aug 18 17:47:21 UTC 2013


On 18 August 2013 17:19, Kamil Rytarowski <n54 at gmx.com> wrote:
> There are two main implementations of basename() in the GNU system, one is
> libgen.h and one from string.h (being accessible here as _GNU_SOURCE).
> Currently we do not support systems other than with GNU Lib C (except
> possible compatibility layers), because we assume the basename() is shipped
> with string.h.
>
> There is a fundamental question before adding a header of libgen.h: the
> POSIX standard explicitly allows to modify the input -- is it acceptable?
>
> Should be there a rewriten a xbasename() version of this function to make
> sure it's portable across systems?

See man basename or http://man7.org/linux/man-pages/man3/basename.3.html#BUGS :
"BUGS
       In the glibc implementation of the POSIX versions of these
functions they modify their argument, and segfault when called with a
static string  like  "/usr/"."

And I can guaranty you from my previous experience with other non GNU libc
that the odds're very high that you'll indeed get strange segfaults
My 2 cents


More information about the Rpm-maint mailing list