This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/11092] c_printstr in c-lang.c length parameter can overflow
- From: "schwab at linux-m68k dot org" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 15 Dec 2009 16:37:46 -0000
- Subject: [Bug gdb/11092] c_printstr in c-lang.c length parameter can overflow
- References: <20091215144649.11092.pmuldoon@redhat.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From schwab at linux-m68k dot org 2009-12-15 16:37 -------
You're right, I missed that. This patch should fix that:
--- c-lang.c.~1.78.~ 2009-09-28 11:42:34.000000000 +0200
+++ c-lang.c 2009-12-15 17:27:21.000000000 +0100
@@ -386,6 +386,18 @@ c_printstr (struct ui_file *stream, stru
int finished = 0;
int need_escape = 0;
+ if (length == -1)
+ {
+ unsigned long current_char = 1;
+ for (i = 0; current_char; ++i)
+ {
+ QUIT;
+ current_char = extract_unsigned_integer (string + i * width,
+ width, byte_order);
+ }
+ length = i;
+ }
+
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
style. */
@@ -417,18 +429,6 @@ c_printstr (struct ui_file *stream, stru
return;
}
- if (length == -1)
- {
- unsigned long current_char = 1;
- for (i = 0; current_char; ++i)
- {
- QUIT;
- current_char = extract_unsigned_integer (string + i * width,
- width, byte_order);
- }
- length = i;
- }
-
/* Arrange to iterate over the characters, in wchar_t form. */
iter = make_wchar_iterator (string, length * width, encoding, width);
cleanup = make_cleanup_wchar_iterator (iter);
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11092
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.