kern___realpathat(): honor uio_seg argument

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47739
This commit is contained in:
Konstantin Belousov 2024-11-25 16:07:15 +02:00
parent 67218bcea8
commit bde575b273

View File

@ -3290,7 +3290,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: