The kernel does not copy more than PATH_MAX bytes from userspace
pathnames, treating non-NUL-terminated pathnames as ENAMETOOLONG.
* util.c (printpathn): Decrease buffer size to PATH_MAX.
(printpath): Specify PATH_MAX - 1 as the maximum pathname length
to match the kernel behaviour. The underlying umovestr call will fetch
up to PATH_MAX bytes from tracee's memory, but no more than first
PATH_MAX - 1 bytes will be printed.
void
printpathn(struct tcb *const tcp, const kernel_ulong_t addr, unsigned int n)
{
- char path[PATH_MAX + 1];
+ char path[PATH_MAX];
int nul_seen;
if (!addr) {
printpath(struct tcb *const tcp, const kernel_ulong_t addr)
{
/* Size must correspond to char path[] size in printpathn */
- printpathn(tcp, addr, PATH_MAX);
+ printpathn(tcp, addr, PATH_MAX - 1);
}
/*