Skip to content

Commit a2dea0b

Browse files
committed
Fix handling of corrupt STABS enum type strings.
PR binutils/21157 * stabs.c (parse_stab_enum_type): Check for corrupt NAME:VALUE pairs. (parse_number): Exit early if passed an empty string.
1 parent b32e566 commit a2dea0b

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎binutils/ChangeLog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-02-14 Nick Clifton <nickc@redhat.com>
2+
3+
PR binutils/21157
4+
* stabs.c (parse_stab_enum_type): Check for corrupt NAME:VALUE
5+
pairs.
6+
(parse_number): Exit early if passed an empty string.
7+
18
2017-02-14 Nick Clifton <nickc@redhat.com>
29

310
PR binutils/21155

‎binutils/stabs.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ parse_number (const char **pp, bfd_boolean *poverflow)
232232

233233
orig = *pp;
234234

235+
/* Stop early if we are passed an empty string. */
236+
if (*orig == 0)
237+
return (bfd_vma) 0;
238+
235239
errno = 0;
236240
ul = strtoul (*pp, (char **) pp, 0);
237241
if (ul + 1 != 0 || errno == 0)
@@ -1975,9 +1979,17 @@ parse_stab_enum_type (void *dhandle, const char **pp)
19751979
bfd_signed_vma val;
19761980

19771981
p = *pp;
1978-
while (*p != ':')
1982+
while (*p != ':' && *p != 0)
19791983
++p;
19801984

1985+
if (*p == 0)
1986+
{
1987+
bad_stab (orig);
1988+
free (names);
1989+
free (values);
1990+
return DEBUG_TYPE_NULL;
1991+
}
1992+
19811993
name = savestring (*pp, p - *pp);
19821994

19831995
*pp = p + 1;

0 commit comments

Comments
 (0)