Skip to content

Commit

Permalink
Fix: illegal memory access in test_create_kernel_event
Browse files Browse the repository at this point in the history
Found by Coverity:
CID 1243030 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)1.
buffer_size_warning: Calling strncpy with a maximum size argument of 256
bytes on destination array ev.name of size 256 bytes might leave the
destination string unterminated.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Signed-off-by: Jérémie Galarneau <[email protected]>
  • Loading branch information
compudj authored and jgalar committed May 17, 2016
1 parent 1b0eb86 commit 1c0733d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/unit/test_kernel_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define RANDOM_STRING_LEN 11

/* Number of TAP tests in this file */
#define NUM_TESTS 10
#define NUM_TESTS 11

/* For error.h */
int lttng_opt_quiet = 1;
Expand Down Expand Up @@ -134,7 +134,9 @@ static void test_create_kernel_event(void)
struct lttng_event ev;

memset(&ev, 0, sizeof(ev));
strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN);
ok(lttng_strncpy(ev.name, get_random_string(),
LTTNG_KERNEL_SYM_NAME_LEN),
"Validate string length");
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;

Expand Down

0 comments on commit 1c0733d

Please sign in to comment.