Skip to content

Commit c16954a

Browse files
compudjjgalar
authored andcommitted
Fix: illegal memory access in test_create_ust_channel
Found by Coverity: CID 1243032 (#1 of 1): Buffer not null terminated (BUFFER_SIZE)1. buffer_size: Calling strncpy with a source string whose length (8 chars) is greater than or equal to the size argument (8) will fail to null-terminate attr.name. Signed-off-by: Mathieu Desnoyers <[email protected]>
1 parent fa3bcac commit c16954a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/unit/test_ust_data.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define RANDOM_STRING_LEN 11
3939

4040
/* Number of TAP tests in this file */
41-
#define NUM_TESTS 12
41+
#define NUM_TESTS 13
4242

4343
/* For error.h */
4444
int lttng_opt_quiet = 1;
@@ -101,8 +101,8 @@ static void test_create_ust_channel(void)
101101

102102
memset(&attr, 0, sizeof(attr));
103103

104-
strncpy(attr.name, "channel0", 8);
105-
104+
ok(lttng_strncpy(attr.name, "channel0", sizeof(attr.name)) == 0,
105+
"Validate channel name length");
106106
uchan = trace_ust_create_channel(&attr, LTTNG_DOMAIN_UST);
107107
ok(uchan != NULL, "Create UST channel");
108108

0 commit comments

Comments
 (0)