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.
+2013-07-16 Andrew Burgess <aburgess@broadcom.com>
+
+ * common/format.c (parse_format_string): Add checks for NULL
+ character before calling strchr.
+
2013-07-16 Doug Evans <dje@google.com>
* solist.h (target_so_ops.find_and_open_solib): Clarify usage of
2013-07-16 Doug Evans <dje@google.com>
* solist.h (target_so_ops.find_and_open_solib): Clarify usage of
/* The first part of a format specifier is a set of flag
characters. */
/* 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;
{
if (*f == '#')
seen_hash = 1;
}
/* The next part of a format specifier is a width. */
}
/* 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. */
f++;
/* The next part of a format specifier is a precision. */
- while (strchr ("0123456789", *f))
+ while (*f != '\0' && strchr ("0123456789", *f))
+2013-07-16 Andrew Burgess <aburgess@broadcom.com>
+
+ * gdb.base/printcmds.exp (test_printf): Add tests for format
+ strings with missing format specifier.
+
2013-07-16 Tom Tromey <tromey@redhat.com>
* gdb.ada/info_types.exp: Use standard_testfile.
2013-07-16 Tom Tromey <tromey@redhat.com>
* gdb.ada/info_types.exp: Use standard_testfile.
# Regression test for "%% at end of format string.
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11345
gdb_test "printf \"%%%d%%\\n\", 5" "%5%"
# Regression test for "%% at end of format string.
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11345
gdb_test "printf \"%%%d%%\\n\", 5" "%5%"
+
+ # Some tests for missing format specifier after '%'.
+ gdb_test "printf \"%\", 0" "Incomplete format specifier at end of format string"
+ gdb_test "printf \"%.234\", 0" "Incomplete format specifier at end of format string"
+ gdb_test "printf \"%-\", 0" "Incomplete format specifier at end of format string"
+ gdb_test "printf \"%-23\", 0" "Incomplete format specifier at end of format string"
}
#Test printing DFP values with printf
}
#Test printing DFP values with printf