<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/stdlib/realpath.c, branch release/13.1.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F13.1.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F13.1.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2020-02-20T16:58:19Z</updated>
<entry>
<title>vfs: add realpathat syscall</title>
<updated>2020-02-20T16:58:19Z</updated>
<author>
<name>Mateusz Guzik</name>
<email>mjg@FreeBSD.org</email>
</author>
<published>2020-02-20T16:58:19Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=0573d0a9b8ec478348cbf2a7ec370c875eb57dff'/>
<id>urn:sha1:0573d0a9b8ec478348cbf2a7ec370c875eb57dff</id>
<content type='text'>
realpath(3) is used a lot e.g., by clang and is a major source of getcwd
and fstatat calls. This can be done more efficiently in the kernel.

This works by performing a regular lookup while saving the name and found
parent directory. If the terminal vnode is a directory we can resolve it using
usual means. Otherwise we can use the name saved by lookup and resolve the
parent.

See the review for sample syscall counts.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23574
</content>
</entry>
<entry>
<title>Fix -Wsign-compare warnings in realpath.c</title>
<updated>2019-06-26T15:43:20Z</updated>
<author>
<name>Alex Richardson</name>
<email>arichardson@FreeBSD.org</email>
</author>
<published>2019-06-26T15:43:20Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=df5e39248342eb6579361b756fb07d2ee08e6955'/>
<id>urn:sha1:df5e39248342eb6579361b756fb07d2ee08e6955</id>
<content type='text'>
This is needed in order to build realpath.c as part of rtld.
</content>
</entry>
<entry>
<title>libc: further adoption of SPDX licensing ID tags.</title>
<updated>2017-11-25T17:12:48Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-11-25T17:12:48Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d915a14ef094c8dfc1a5aee70e135abfec01d0f1'/>
<id>urn:sha1:d915a14ef094c8dfc1a5aee70e135abfec01d0f1</id>
<content type='text'>
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
</content>
</entry>
<entry>
<title>Style.</title>
<updated>2017-05-15T17:54:36Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2017-05-15T17:54:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=cf5cedd78512db4977037e04d5011ae4f020204c'/>
<id>urn:sha1:cf5cedd78512db4977037e04d5011ae4f020204c</id>
<content type='text'>
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>Simplify cleanup on failure in realpath(3).</title>
<updated>2017-05-15T17:34:17Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2017-05-15T17:34:17Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d933a4c06b742a42c4ca94951be231b053032436'/>
<id>urn:sha1:d933a4c06b742a42c4ca94951be231b053032436</id>
<content type='text'>
If realpath() allocated memory for result and failed, the memory is
freed in each place where return is performed.  More, the function
needs to track the allocation status, to not free user-supplied
buffer.

Consolidate the memory handling in the wrapper, freeing the buffer if
the actual worker failed.

Reviewed by:	emaste (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D10670
</content>
</entry>
<entry>
<title>Fix several buffer overflows in realpath(3).</title>
<updated>2017-05-15T17:14:53Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2017-05-15T17:14:53Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=f81e5b2d9bd4d0199bed864cafb12422cc1d71b6'/>
<id>urn:sha1:f81e5b2d9bd4d0199bed864cafb12422cc1d71b6</id>
<content type='text'>
- The statement "left_len -= s - left;" does not take the slash into
  account if one was found. This results in the invariant
  "left[left_len] == '\0'" being violated (and possible buffer
  overflows). The patch replaces the variable "s" with a size_t
  "next_token_len" for more clarity.
- "slen" from readlink(2) can be 0 when encountering empty
  symlinks. Then, further down, "symlink[slen - 1]" underflows the
  buffer. When slen == 0, realpath(3) should probably return ENOENT
  (http://austingroupbugs.net/view.php?id=825,
  https://lwn.net/Articles/551224/).

Some other minor issues:
- The condition "resolved_len &gt;= PATH_MAX" cannot be true.
- Similarly, "s - left &gt;= sizeof(next_token)" cannot be true, as long
  as "sizeof(next_token) &gt;= sizeof(left)".
- Return ENAMETOOLONG when a resolved symlink from readlink(2) is too
  long for the symlink buffer (instead of just truncating it).
- "resolved_len &gt; 1" below the call to readlink(2) is always true as
  "strlcat(resolved, next_token, PATH_MAX);" always results in a
  string of length &gt; 1. Also, "resolved[resolved_len - 1] = '\0';" is
  not needed; there can never be a trailing slash here.
- The truncation check for "strlcat(symlink, left, sizeof(symlink));"
  should be against "sizeof(symlink)" (the third argument to strlcat)
  instead of "sizeof(left)".

Submitted by:	Jan Kokemц╪ller &lt;jan.kokemueller@gmail.com&gt;
PR:	219154
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>realpath(): Properly fail "." or ".." components after non-directories.</title>
<updated>2014-04-13T19:48:28Z</updated>
<author>
<name>Jilles Tjoelker</name>
<email>jilles@FreeBSD.org</email>
</author>
<published>2014-04-13T19:48:28Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=310c8f3c99499326d1053ce811348bf2e35e09af'/>
<id>urn:sha1:310c8f3c99499326d1053ce811348bf2e35e09af</id>
<content type='text'>
If realpath() is called on pathnames like "/dev/null/." or "/dev/null/..",
it should fail with [ENOTDIR]. Pathnames like "/dev/null/" already failed as
they should.

Also, put the check for non-directories after lstatting the previous
component instead of when the empty component (consecutive or trailing
slashes) is detected, saving an lstat() call and some lines of code.

PR:		kern/82980
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>- Correct mispellings of the word occurrence</title>
<updated>2013-04-17T11:40:10Z</updated>
<author>
<name>Gabor Kovesdan</name>
<email>gabor@FreeBSD.org</email>
</author>
<published>2013-04-17T11:40:10Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=ab3f6b347ef97e755cf291ed77f9eb4a48531d15'/>
<id>urn:sha1:ab3f6b347ef97e755cf291ed77f9eb4a48531d15</id>
<content type='text'>
Submitted by:	Christoph Mallon &lt;christoph.mallon@gmx.de&gt; (via private mail)
</content>
</entry>
<entry>
<title>Avoid mapping ENOENT to ENOTDIR for non-existent path components.</title>
<updated>2012-09-12T17:05:39Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2012-09-12T17:05:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=7877ed7ce33ed9b977ac9b521f9a2f95b5d589bd'/>
<id>urn:sha1:7877ed7ce33ed9b977ac9b521f9a2f95b5d589bd</id>
<content type='text'>
The ENOTDIR mapping was introduced in r235266 for kern/128933 based on
an interpretation of the somewhat ambiguous language in the POSIX realpath
specification.  The interpretation is inconsistent with Solaris and Linux,
a regression from 9.0, and does not appear to be permitted by the
description of ENOTDIR:

     20 ENOTDIR Not a directory.  A component of the specified pathname
             existed, but it was not a directory, when a directory was
             expected.

PR:		standards/171577
MFC after:	3 days
</content>
</entry>
<entry>
<title>1) Although unpublished version of standard</title>
<updated>2012-06-05T16:16:33Z</updated>
<author>
<name>Andrey A. Chernov</name>
<email>ache@FreeBSD.org</email>
</author>
<published>2012-06-05T16:16:33Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=5f5a50728c89942f4c223cc8856ae1f978549240'/>
<id>urn:sha1:5f5a50728c89942f4c223cc8856ae1f978549240</id>
<content type='text'>
http://austingroupbugs.net/view.php?id=385#c713
(Resolved state) recommend this way for the current standard (called
"earlier" in the text)

"However, earlier versions of this standard did not require this, and the
same example had to be written as:

    // buf was obtained by malloc(buflen)
    ret = write(fd, buf, buflen);
    if (ret &lt; 0) {
        int save = errno;
        free(buf);
        errno = save;
        return ret;
    }
"

from feedback I have for previous commit it seems that many people prefer
to avoid mass code change needed for current standard compliance
and prefer to track unpublished standard instead, which requires now
that free() itself must save errno, not its usage code.

So, I back out "save errno across free()" part of previous commit,
and will fill PR for changing free() isntead.

2) Remove now unused serrno.

MFC after:      1 week
</content>
</entry>
</feed>
