Skip to contentSkip to conversation

libsemanage: fix fname[] initialization in test_utilities.c

PATCH Applied Petr Lautrbach 2 participants 2 messages Mar 16, 2015 – Mar 18, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsemanage: fix fname[] initialization in test_utilities.c

There's no guaranty that last item in "char fname[]" will be a null character. Fixes segfault on some systems:

Test: semanage_nc_sort ...passedtest_semanage_findval: : Invalid argument
libsemanage-tests: TestRun.c:160: CU_assertImplementation: Assertion `((void *)0) != f_pCurTest' failed. make[1]: *** [test] Aborted (core dumped)

---
 libsemanage/tests/test_utilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/tests/test_utilities.c +1 -1
index 4d25b07..32cc33c 100644
@@ -45,7 +45,7 @@ void test_slurp_file_filter(void);
 
 char fname[] = {
 	'T', 'E', 'S', 'T', '_', 'T', 'E', 'M', 'P', '_', 'X', 'X', 'X', 'X',
-	'X', 'X'
+	'X', 'X', '\0'
 };
 int fd;
 FILE *fptr;
Signature · 1 line
2.3.1
#1 lore raw
Quoted 18 lines · Petr Lautrbach

There's no guaranty that last item in "char fname[]" will be a null character. Fixes segfault on some systems:

Test: semanage_nc_sort ...passedtest_semanage_findval: : Invalid argument
libsemanage-tests: TestRun.c:160: CU_assertImplementation: Assertion `((void *)0) != f_pCurTest' failed. make[1]: *** [test] Aborted (core dumped)

---
 libsemanage/tests/test_utilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/tests/test_utilities.c +0 -0
index 4d25b07..32cc33c 100644

libsemanage/tests/test_utilities.c void test_slurp_file_filter(void); · line 51

Quoted 8 lines
libsemanage/tests/test_utilities.c +1 -1
@@ -45,7 +45,7 @@ void test_slurp_file_filter(void);
 
 char fname[] = {
 	'T', 'E', 'S', 'T', '_', 'T', 'E', 'M', 'P', '_', 'X', 'X', 'X', 'X',
-	'X', 'X'
+	'X', 'X', '\0'
 };
 int fd;
 FILE *fptr;

Thanks, applied.