From: Andrey Volk Date: Mon, 24 Jul 2023 13:20:20 +0000 (+0300) Subject: [Unit-tests] Fix possible overflows and an undefined variable in the test framework. X-Git-Tag: v1.10.10^2~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2176%2Fhead;p=thirdparty%2Ffreeswitch.git [Unit-tests] Fix possible overflows and an undefined variable in the test framework. --- diff --git a/src/include/test/switch_fct.h b/src/include/test/switch_fct.h index 8cb07cc20f..b28feabb74 100644 --- a/src/include/test/switch_fct.h +++ b/src/include/test/switch_fct.h @@ -255,7 +255,7 @@ fctstr_safe_cpy(char *dst, char const *src, size_t num) #if defined(WIN32) && _MSC_VER >= 1400 strncpy_s(dst, num, src, _TRUNCATE); #else - strncpy(dst, src, num); + strncpy(dst, src, num - 1); #endif dst[num-1] = '\0'; } @@ -760,6 +760,7 @@ fct_nlist__init2(fct_nlist_t *list, size_t start_sz) list->itm_list = (void**)malloc(sizeof(void*)*start_sz); if ( list->itm_list == NULL ) { + list->used_itm_num = 0; return 0; } }