mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-30 00:52:16 +08:00
Fix buffer underflow in add_path
Address sanitizer pointed out a buglet in source.c:add_path. In this test, from gdb.base/source-dir.exp: (gdb) set directories :/foo:/bar ... 'p[-1]' will result in a buffer underflow. This patch fixes the bug by introducing a new check. 2021-05-17 Tom Tromey <tromey@adacore.com> * source.c (add_path): Check 'p' before using 'p[-1]'.
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
2021-05-17 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* source.c (add_path): Check 'p' before using 'p[-1]'.
|
||||
|
||||
2021-05-17 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* dwarf2/read.h (struct dwarf2_per_cu_data_deleter: New.
|
||||
|
@ -537,6 +537,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
||||
/* On MS-DOS and MS-Windows, h:\ is different from h: */
|
||||
&& !(p == name + 3 && name[1] == ':') /* "d:/" */
|
||||
#endif
|
||||
&& p > name
|
||||
&& IS_DIR_SEPARATOR (p[-1]))
|
||||
/* Sigh. "foo/" => "foo" */
|
||||
--p;
|
||||
|
Reference in New Issue
Block a user