printpath: do not fetch more than PATH_MAX bytes from tracee's memory
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.
This commit is contained in:
parent
ce822389af
commit
d7a45f8dcc
4
util.c
4
util.c
@ -715,7 +715,7 @@ print_quoted_cstring(const char *str, unsigned int size)
|
||||
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) {
|
||||
@ -741,7 +741,7 @@ void
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user