<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/gen/basename.c, branch releng/12.4</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2016-11-03T20:21:34Z</updated>
<entry>
<title>Replace basename(3) by a thread-safe implementation.</title>
<updated>2016-11-03T20:21:34Z</updated>
<author>
<name>Ed Schouten</name>
<email>ed@FreeBSD.org</email>
</author>
<published>2016-11-03T20:21:34Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=34168b28e99b0bb328c7bb49cd91cb942181056f'/>
<id>urn:sha1:34168b28e99b0bb328c7bb49cd91cb942181056f</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>Fix up prototypes of basename(3) and dirname(3) to comply to POSIX.</title>
<updated>2016-07-28T16:20:27Z</updated>
<author>
<name>Ed Schouten</name>
<email>ed@FreeBSD.org</email>
</author>
<published>2016-07-28T16:20:27Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=938809f9411ca770cd11d6e96fb384050a52f7d8'/>
<id>urn:sha1:938809f9411ca770cd11d6e96fb384050a52f7d8</id>
<content type='text'>
POSIX allows these functions to be implemented in a way that the
resulting string is stored in the input buffer. Though some may find
this annoying, this has the advantage that it makes it possible to
implement this function in a thread-safe way. It also means that they
can be implemented in a way that they work for paths of arbitrary
length, as the output string of these functions is never longer than
max(1, len(input)).

Portable code already needs to be written with this in mind, so in my
opinion it makes very little sense to allow the existing behaviour.
Prevent the base system from falling back to this by switching over to
POSIX prototypes.

I'm not going to bump the __FreeBSD_version for this. The reason is that
it's possible to account for this change in a portable way, without
depending on a specific version of FreeBSD. An exp-run was done some
time ago. As far as I know, all regressions as a result of this have
already been fixed.

I'll give this change some time to settle. In the long run I want to
replace our copies by ones that are thread-safe and don't depend on
PATH_MAX/MAXPATHLEN.
</content>
</entry>
<entry>
<title>Sync with OpenBSD, primarily make the code easier to read, and a license</title>
<updated>2011-06-18T00:33:34Z</updated>
<author>
<name>Xin LI</name>
<email>delphij@FreeBSD.org</email>
</author>
<published>2011-06-18T00:33:34Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=488d6e0c3dbc6e79f9275da9adf75294cbe9fbd6'/>
<id>urn:sha1:488d6e0c3dbc6e79f9275da9adf75294cbe9fbd6</id>
<content type='text'>
change to standard OpenBSD ISC license.

Obtained from:	OpenBSD
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>Add basename_r(3) to complement basename(3).  basename_r(3) which accepts</title>
<updated>2009-10-06T14:05:57Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2009-10-06T14:05:57Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a502a84d5a0d6c3cf180278d39bf25bbf5313fd9'/>
<id>urn:sha1:a502a84d5a0d6c3cf180278d39bf25bbf5313fd9</id>
<content type='text'>
a caller-allocated buffer of at least MAXPATHLEN, rather than using a
global buffer.

MFC after:	1 month
Sponsored by:	Google
</content>
</entry>
<entry>
<title>Fix LP64 architectures and especially ia64. Functions that return</title>
<updated>2002-12-30T01:41:14Z</updated>
<author>
<name>Marcel Moolenaar</name>
<email>marcel@FreeBSD.org</email>
</author>
<published>2002-12-30T01:41:14Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=2bc46a64529175d805900dab5db72ab615e1eab2'/>
<id>urn:sha1:2bc46a64529175d805900dab5db72ab615e1eab2</id>
<content type='text'>
a pointer and lack a prototype will have the return value (assumed
to be an integer) zero-extended to a pointer. On ia64 this is
unconditionally fatal as it zeroes-out the region bits, forming an
invalid pointer. Fix the sigsegv by including &lt;stdlib.h&gt;.

Pointy hat: bbraun
</content>
</entry>
<entry>
<title>Reduce libc.so's memory footprint by lazily allocating memory used internally</title>
<updated>2002-12-21T07:12:35Z</updated>
<author>
<name>Rob Braun</name>
<email>bbraun@FreeBSD.org</email>
</author>
<published>2002-12-21T07:12:35Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=5fb691beab21abbda50f3c51287b0f89f8a2fc85'/>
<id>urn:sha1:5fb691beab21abbda50f3c51287b0f89f8a2fc85</id>
<content type='text'>
by basename() and dirname().
Reviewed by: eric
</content>
</entry>
<entry>
<title>* Remove 'register'.  (some functions had 7+ register functions...)</title>
<updated>2002-02-01T01:08:48Z</updated>
<author>
<name>David E. O'Brien</name>
<email>obrien@FreeBSD.org</email>
</author>
<published>2002-02-01T01:08:48Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=22626efa0f96cbca4edae882e46cb56b1879706b'/>
<id>urn:sha1:22626efa0f96cbca4edae882e46cb56b1879706b</id>
<content type='text'>
* Fix SCM ID's.
</content>
</entry>
<entry>
<title>Fixed world breakage due to missing include of &lt;sys/cdefs.h&gt; in previous</title>
<updated>2002-01-31T12:58:36Z</updated>
<author>
<name>Bruce Evans</name>
<email>bde@FreeBSD.org</email>
</author>
<published>2002-01-31T12:58:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=56bcbf00e27de12298bc3d6de9d6925b6f431145'/>
<id>urn:sha1:56bcbf00e27de12298bc3d6de9d6925b6f431145</id>
<content type='text'>
commit.

Fixed related style bugs:
basename.c: misplaced '#if 0'
dirname.c: misplaced '#if 0'
getgrent.c: missing '#if 0', and tab lossage in vendor id (the previous
            commit fixed the complete corruption of the vendor id but
	    lost a tab)
getpwent.c: missing '#if 0'
</content>
</entry>
<entry>
<title>Fix FreeBSD IDs.</title>
<updated>2002-01-30T21:36:57Z</updated>
<author>
<name>David E. O'Brien</name>
<email>obrien@FreeBSD.org</email>
</author>
<published>2002-01-30T21:36:57Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=135b57f90661881927208fdb34475cfd44b4f0be'/>
<id>urn:sha1:135b57f90661881927208fdb34475cfd44b4f0be</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix a one-byte overrun.</title>
<updated>2001-06-28T21:50:53Z</updated>
<author>
<name>Dima Dorfman</name>
<email>dd@FreeBSD.org</email>
</author>
<published>2001-06-28T21:50:53Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=ff5f0dbc4116ecea47fcacf10db7f6807b6d063b'/>
<id>urn:sha1:ff5f0dbc4116ecea47fcacf10db7f6807b6d063b</id>
<content type='text'>
PR:		28472
Submitted by:	David Xu &lt;davidx@viasoft.com.cn&gt;
Obtained from:	OpenBSD
</content>
</entry>
</feed>
