Преглед на файлове

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 години
родител
ревизия
24a2f4f300
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  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);
 }