syscalls/ioctl_ns05,6: Fix buffer overflow
PATCH 1/1 syscalls/ioctl_ns05,6: Fix buffer overflow
Since pid's max value is 2147483647, the child_namespace maybe not enough to store "/proc/%s/ns/user" string when using a large pid. Fix it by improving the length to 30.
--- testcases/kernel/syscalls/ioctl/ioctl_ns05.c | 2 +- testcases/kernel/syscalls/ioctl/ioctl_ns06.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_ns05.c +1 -1
@@ -59,7 +59,7 @@ static void run(void)if (pid ==-1 )tst_brk (TBROK |TERRNO ,"ltp_clone failed" ); -char child_namespace[20 ]; +char child_namespace[30 ];int my_fd, child_fd, parent_fd;sprintf (child_namespace,"/proc/%i/ns/pid" , pid);
testcases/kernel/syscalls/ioctl/ioctl_ns06.c +1 -1
@@ -51,7 +51,7 @@ static int child(void *arg LTP_ATTRIBUTE_UNUSED)static void run (void ) { -char child_namespace[20 ]; +char child_namespace[30 ];pid_t pid =ltp_clone (CLONE_NEWUSER |SIGCHLD , &child,0 ,STACK_SIZE , child_stack);
Signature · 1 line
2.23.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 syscalls/ioctl_ns05,6: Fix buffer overflow
Hi Marius
cc ltp list
Quoted 3 lines
Hi Yang,
Thanks for your patch! I had missed your email before submitting my PR.
It doesn't matter.
Quoted 2 lines
What do you think about also turning the
sprintf()intosnprintf()?
I have no objection for using snprintf.
Also, ltp usually accepts patch from mailing list instead of pull request.
ps: cc ltp guys, so other maintainers will know I have no objection for your patch.
Best Regards
Yang Xu
Quoted 3 lines
Regards,
Marius