X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Funit%2Ftest_ust_data.cpp;h=9cfdac4f31c08473d82ae10ad206dc2c28577191;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hp=04aa8c83eb994c7dc7c7fc29ddec466391047705;hpb=f46376a14da2eb796690cb4e718e8b213839d6ea;p=lttng-tools.git diff --git a/tests/unit/test_ust_data.cpp b/tests/unit/test_ust_data.cpp index 04aa8c83e..9cfdac4f3 100644 --- a/tests/unit/test_ust_data.cpp +++ b/tests/unit/test_ust_data.cpp @@ -13,12 +13,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include @@ -143,6 +143,7 @@ static void test_create_ust_event(void) static void test_create_ust_event_exclusion(void) { + int copy_ret; enum lttng_error_code ret; struct ltt_ust_event *event; struct lttng_event ev; @@ -206,16 +207,24 @@ static void test_create_ust_event_exclusion(void) */ exclusion->count = exclusion_count; - strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0), - get_random_string(), LTTNG_SYMBOL_NAME_LEN - 1); - strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), - get_random_string(), LTTNG_SYMBOL_NAME_LEN - 1); + copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0), + get_random_string(), + sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0))); + LTTNG_ASSERT(copy_ret == 0); + copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), + get_random_string(), + sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1))); + LTTNG_ASSERT(copy_ret == 0); exclusion_copy->count = exclusion_count; - strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0), - LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0), LTTNG_SYMBOL_NAME_LEN); - strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1), - LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), LTTNG_SYMBOL_NAME_LEN); + copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0), + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0), + sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0))); + LTTNG_ASSERT(copy_ret == 0); + copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1), + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), + sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1))); + LTTNG_ASSERT(copy_ret == 0); ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event); exclusion = NULL;