From: David Goulet Date: Wed, 1 Oct 2014 17:30:27 +0000 (-0400) Subject: Fix: detect size_t overflow in syscall table init X-Git-Tag: v2.6.0-rc1~22 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=1f47715a589b81c62de8fd49a342bf4cf4be770a Fix: detect size_t overflow in syscall table init Fixes Coverity issue 1242317. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/syscall.c b/src/bin/lttng-sessiond/syscall.c index ee7578051..b4f2e1eca 100644 --- a/src/bin/lttng-sessiond/syscall.c +++ b/src/bin/lttng-sessiond/syscall.c @@ -35,7 +35,7 @@ static size_t syscall_table_nb_entry; * Populate the system call table using the kernel tracer. * * Return 0 on success and the syscall table is allocated. On error, a negative - * value is returned and the syscall table is set to NULL. + * value is returned. */ int syscall_init_table(void) { @@ -82,6 +82,14 @@ int syscall_init_table(void) /* Double memory size. */ new_nbmem = max(index, nbmem << 1); + if (new_nbmem < nbmem) { + /* Overflow, stop everything, something went really wrong. */ + ERR("Syscall listing memory size overflow. Stopping"); + free(syscall_table); + syscall_table = NULL; + ret = -EINVAL; + goto error; + } DBG("Reallocating syscall table from %zu to %zu entries", nbmem, new_nbmem);