Add paranoia check before passing a long to pid2tcb(int pid)

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2013-07-04 09:26:24 +02:00
parent 38eab5d6ea
commit 6162a3f34f

View File

@ -2097,6 +2097,9 @@ trace(void)
if (ptrace(PTRACE_GETEVENTMSG, pid, NULL, (long) &old_pid) < 0)
goto dont_switch_tcbs;
/* Avoid truncation in pid2tcb() param passing */
if (old_pid > UINT_MAX)
goto dont_switch_tcbs;
if (old_pid <= 0 || old_pid == pid)
goto dont_switch_tcbs;
execve_thread = pid2tcb(old_pid);