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 a766bd8af69bea294a68b1d38f83dc0a339893d1..2df645f213c77d39d1fa37257767049bddd601a6 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 ec0b0ee74940831f760f0c9857b544df23c42baa..2ff2af8a59c65827b5dd815bf948bdf3a04b8075 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;