Explorar o código

libcompat: Do not NULL-terminate the list in scandir()

This might cause a segfault in case all entries have been filtered and
list has not been allocated. This should only possibly affect systems
where the fallback code is being used.
Guillem Jover %!s(int64=12) %!d(string=hai) anos
pai
achega
f470bfb33f
Modificáronse 2 ficheiros con 2 adicións e 1 borrados
  1. 2 0
      debian/changelog
  2. 0 1
      lib/compat/scandir.c

+ 2 - 0
debian/changelog

@@ -75,6 +75,8 @@ dpkg (1.17.2) UNRELEASED; urgency=low
     describing in the man page the default output files.
   * Use “hyphen” instead of “dash” when we mean the ‘-’ character in the
     documentation and code comments.
+  * Do not NULL-terminate the list in the compat scandir(), as this might
+    cause a segfault in case the function returns 0 entries.
 
   [ Updated programs translations ]
   * German (Sven Joachim).

+ 0 - 1
lib/compat/scandir.c

@@ -85,7 +85,6 @@ scandir(const char *dir, struct dirent ***namelist,
 		list[used] = m;
 		used++;
 	}
-	list[used] = NULL;
 
 	closedir(d);