From: Tim Ruehsen Date: Fri, 6 Dec 2019 22:20:06 +0000 (+0000) Subject: Fix read buffer overflow in split_directories X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1cd4fe3d4302f0db3dd38c720c69f0c51137ff13;p=gcc.git Fix read buffer overflow in split_directories * make-relative-prefix.c (split_directories): Return early on empty 'name' From-SVN: r279068 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a766bd8af69..2df645f213c 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2019-12-06 Tim Ruehsen + + * make-relative-prefix.c (split_directories): + Return early on empty 'name' + 2019-11-16 Tim Ruehsen * cp-demangle.c (d_print_init): Remove const from 4th param. diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c index ec0b0ee7494..2ff2af8a59c 100644 --- a/libiberty/make-relative-prefix.c +++ b/libiberty/make-relative-prefix.c @@ -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;