]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Unit-tests] Fix possible overflows and an undefined variable in the test framework. 2176/head
authorAndrey Volk <andywolk@gmail.com>
Mon, 24 Jul 2023 13:20:20 +0000 (16:20 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 24 Jul 2023 18:23:53 +0000 (21:23 +0300)
src/include/test/switch_fct.h

index 8cb07cc20f7a8ef9731c9cc092aed485e5f366c6..b28feabb742b43f3f420341a396c8ac0353eaaea 100644 (file)
@@ -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;
         }
     }