]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Replace basename(3) by a thread-safe implementation.
authorEd Schouten <ed@FreeBSD.org>
Thu, 3 Nov 2016 20:21:34 +0000 (20:21 +0000)
committerEd Schouten <ed@FreeBSD.org>
Thu, 3 Nov 2016 20:21:34 +0000 (20:21 +0000)
commit34168b28e99b0bb328c7bb49cd91cb942181056f
treed87ccf079f0846f66d2897554768fb78925732fa
parent1bec4c5b3d970c741ffcb08a40080924e6ce97af
Replace basename(3) by a thread-safe implementation.

Now that the changes to the dirname(3) function had some time to settle,
let's go ahead and use the same approach for replacing basename(3) by a
simple implementation that modifies the input string, thereby making it
thread-safe and guaranteed to succeed.

Unlike dirname(3), this function already had a thread-safe variant
basename_r(3). This function had its own set of problems, like having an
upper bound on the pathname length. Keep this function around for
compatibility, but remove most references from the man page. Make the
man page more similar to that of dirname(3).

As the basename_r(3) function is only provided by FreeBSD (and Bionic),
depending on its use is even more implementation defined than assuming
that basename(3) is thread-safe.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D8382
include/libgen.h
lib/libc/gen/Makefile.inc
lib/libc/gen/Symbol.map
lib/libc/gen/basename.3
lib/libc/gen/basename.c
lib/libc/gen/basename_compat.c [new file with mode: 0644]