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.9.0-rc1~220 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=39e3c47a70c252835593bf39d6f206cfb38aec80 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 7ae6682bb..a994da52b 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,