git: 96b72aa66bc9 - stable/14 - kern___realpathat(): honor uio_seg argument
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Dec 2024 01:46:19 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=96b72aa66bc920b2c2d741ccad425a6dec0ccc2b commit 96b72aa66bc920b2c2d741ccad425a6dec0ccc2b Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-11-25 14:07:15 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-12-02 01:44:56 +0000 kern___realpathat(): honor uio_seg argument (cherry picked from commit bde575b273eeb17abe878e43dd018e8373741298) --- sys/kern/vfs_cache.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index aa6141cb0230..ab28540be8a8 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -3203,7 +3203,15 @@ kern___realpathat(struct thread *td, int fd, const char *path, char *buf, &freebuf, &size); } if (error == 0) { - error = copyout(retbuf, buf, min(strlen(retbuf) + 1, size)); + size_t len; + + len = strlen(retbuf) + 1; + if (size < len) + error = ENAMETOOLONG; + else if (pathseg == UIO_USERSPACE) + error = copyout(retbuf, buf, len); + else + memcpy(buf, retbuf, len); free(freebuf, M_TEMP); } out: