From: Mathieu Desnoyers Date: Tue, 17 May 2016 01:42:53 +0000 (-0400) Subject: Fix: illegal memory access in syscall_init_table X-Git-Tag: v2.6.3~45 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c441c3b7473a454d6350086e3aa1b085b74d8142;p=lttng-tools.git Fix: illegal memory access in syscall_init_table Found by Coverity: CID 1243021 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)25. buffer_size_warning: Calling strncpy with a maximum size argument of 255 bytes on destination array (syscall_table + index).name of size 255 bytes might leave the destination string unterminated. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/syscall.c b/src/bin/lttng-sessiond/syscall.c index f79fa8dd8..d5db52932 100644 --- a/src/bin/lttng-sessiond/syscall.c +++ b/src/bin/lttng-sessiond/syscall.c @@ -108,8 +108,13 @@ int syscall_init_table(void) } syscall_table[index].index = index; syscall_table[index].bitness = bitness; - strncpy(syscall_table[index].name, name, - sizeof(syscall_table[index].name)); + if (lttng_strncpy(syscall_table[index].name, name, + sizeof(syscall_table[index].name))) { + ret = -EINVAL; + free(syscall_table); + syscall_table = NULL; + goto error; + } /* DBG("Syscall name '%s' at index %" PRIu32 " of bitness %u", syscall_table[index].name,