2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

restore: avoid an unterminated string

>>>     CID 164715:    (BUFFER_SIZE_WARNING)
>>>     Calling strncpy with a maximum size argument of 16 bytes on
	destination array "thread_args[i].comm" of size 16 bytes might
	leave the destination string unterminated.
3473    strncpy(thread_args[i].comm, core->tc->comm, TASK_COMM_LEN);

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Andrei Vagin
2018-08-23 14:09:49 +03:00
committed by Andrei Vagin
parent d40c702dd8
commit 2b76b3246f

View File

@@ -3462,9 +3462,10 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
goto err;
if (tcore->thread_core->comm)
strncpy(thread_args[i].comm, tcore->thread_core->comm, TASK_COMM_LEN);
strncpy(thread_args[i].comm, tcore->thread_core->comm, TASK_COMM_LEN - 1);
else
strncpy(thread_args[i].comm, core->tc->comm, TASK_COMM_LEN);
strncpy(thread_args[i].comm, core->tc->comm, TASK_COMM_LEN - 1);
thread_args[i].comm[TASK_COMM_LEN - 1] = 0;
if (thread_args[i].pid != pid)
core_entry__free_unpacked(tcore, NULL);