Fix read buffer overflow in split_directories
authorTim Ruehsen <tim.ruehsen@gmx.de>
Fri, 6 Dec 2019 22:20:06 +0000 (22:20 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 6 Dec 2019 22:20:06 +0000 (15:20 -0700)
        * make-relative-prefix.c (split_directories):
        Return early on empty 'name'

From-SVN: r279068

libiberty/ChangeLog
libiberty/make-relative-prefix.c

index a766bd8..2df645f 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-06  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+       * make-relative-prefix.c (split_directories):
+       Return early on empty 'name'
+
 2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>
 
        * cp-demangle.c (d_print_init): Remove const from 4th param.
index ec0b0ee..2ff2af8 100644 (file)
@@ -122,6 +122,9 @@ split_directories (const char *name, int *ptr_num_dirs)
   const char *p, *q;
   int ch;
 
+  if (!*name)
+    return NULL;
+
   /* Count the number of directories.  Special case MSDOS disk names as part
      of the initial directory.  */
   p = name;