Przeglądaj źródła

Fix a potential buffer overflow

strncpy wouldn't append the null byte in case the source
string length is >= destination buffer.

's_test_directory' is already zero initialized. So leaving
the last byte alone is enough ensure the buffer is null byte
terminated.

Signed-off-by: Ponnuvel Palaniyappan <pponnuvel@gmail.com>
Ponnuvel Palaniyappan 5 lat temu
rodzic
commit
24a2f4f300
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      unittest/shared.c

+ 1 - 1
unittest/shared.c

@@ -44,5 +44,5 @@ set_test_directory(const char *const path)
 {
 	strncpy(s_test_directory,
 	        path,
-	        sizeof(s_test_directory) / sizeof(s_test_directory[0]));
+	        sizeof(s_test_directory) - 1);
 }