From 1cd4fe3d4302f0db3dd38c720c69f0c51137ff13 Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Fri, 6 Dec 2019 22:20:06 +0000 Subject: [PATCH] Fix read buffer overflow in split_directories * make-relative-prefix.c (split_directories): Return early on empty 'name' From-SVN: r279068 --- libiberty/ChangeLog | 5 +++++ libiberty/make-relative-prefix.c | 3 +++ 2 files changed, 8 insertions(+) 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; -- 2.30.2