kern___realpathat(): do not copyout past end of string

Reported and tested by:	pho
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 14:41:46 +02:00
parent 31784ee1e3
commit 67218bcea8

View File

@ -3290,7 +3290,7 @@ kern___realpathat(struct thread *td, int fd, const char *path, char *buf,
&freebuf, &size);
}
if (error == 0) {
error = copyout(retbuf, buf, size);
error = copyout(retbuf, buf, min(strlen(retbuf) + 1, size));
free(freebuf, M_TEMP);
}
out: