PR28862, heap-buffer-overflow in parse_stab_string

I have no info on the format of a "SUNPRO C++ Namespace" stab, so am
relying on the previous code being correct in parsing these stabs.
Just don't allow NULs anywhere in the stab.

	PR 28862
	* stabs.c (parse_stab_string): Don't overrun buffer when parsing
	'Y' stab.
This commit is contained in:
Alan Modra 2022-02-08 20:21:01 +10:30
parent cb5a1d7db9
commit 481153777e

View file

@ -1129,13 +1129,13 @@ parse_stab_string (void *dhandle, struct stab_handle *info, int stabtype,
case 'Y':
/* SUNPro C++ Namespace =Yn0. */
/* Skip the namespace mapping, as it is not used now. */
if (*(++p) == 'n' && *(++p) == '0')
if (*p++ != 0 && *p++ == 'n' && *p++ == '0')
{
/* =Yn0name; */
while (*p != ';')
while (*p && *p != ';')
++p;
++p;
return true;
if (*p)
return true;
}
/* TODO SUNPro C++ support:
Support default arguments after F,P parameters