mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
Check for NULL character before calling strchr.
http://sourceware.org/ml/gdb-patches/2013-07/msg00322.html gdb/ChangeLog * common/format.c (parse_format_string): Add checks for NULL character before calling strchr. gdb/testsuite/ChangeLog * gdb.base/printcmds.exp (test_printf): Add tests for format strings with missing format specifier.
This commit is contained in:
@ -156,7 +156,7 @@ parse_format_string (const char **arg)
|
||||
|
||||
/* The first part of a format specifier is a set of flag
|
||||
characters. */
|
||||
while (strchr ("0-+ #", *f))
|
||||
while (*f != '\0' && strchr ("0-+ #", *f))
|
||||
{
|
||||
if (*f == '#')
|
||||
seen_hash = 1;
|
||||
@ -170,7 +170,7 @@ parse_format_string (const char **arg)
|
||||
}
|
||||
|
||||
/* The next part of a format specifier is a width. */
|
||||
while (strchr ("0123456789", *f))
|
||||
while (*f != '\0' && strchr ("0123456789", *f))
|
||||
f++;
|
||||
|
||||
/* The next part of a format specifier is a precision. */
|
||||
@ -178,7 +178,7 @@ parse_format_string (const char **arg)
|
||||
{
|
||||
seen_prec = 1;
|
||||
f++;
|
||||
while (strchr ("0123456789", *f))
|
||||
while (*f != '\0' && strchr ("0123456789", *f))
|
||||
f++;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user