util: use snprintf for PID formatting in backtrace helper

Use snprintf to make analyziers happier and bump the buffer size to 16.
That's way larger than we'll need given the kernel's PID_MAX_LIMIT
(4194304) but it doesn't cost us anything.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1465>
This commit is contained in:
Peter Hutterer 2026-04-14 07:23:48 +10:00 committed by Marge Bot
parent e32202eeae
commit 9d8a8b4530

View file

@ -65,12 +65,12 @@ backtrace_print(FILE *fp,
child = fork();
if (child == 0) {
char pid[8];
char pid[16];
close(pipefd[0]);
dup2(pipefd[1], STDOUT_FILENO);
sprintf(pid, "%d", parent);
snprintf(pid, sizeof(pid), "%d", parent);
execlp("gstack", "gstack", pid, NULL);
exit(errno);