- Fix gdb printf command argument using "%p" (BZ 205551).

This commit is contained in:
Jan Kratochvil 2006-09-12 17:48:25 +00:00
parent c3984c8e90
commit b6646b39a2
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,54 @@
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=205551
2006-09-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* printcmd.c (printf_command): Handle forgotten "%p".
2006-09-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/display.exp: New test of `printf' "%p" formatting.
diff -u -r sources-clean/gdb/printcmd.c sources-custom/gdb/printcmd.c
--- sources-clean/gdb/printcmd.c 2006-07-29 20:29:26.000000000 +0200
+++ sources-custom/gdb/printcmd.c 2006-09-12 16:18:55.000000000 +0200
@@ -43,6 +43,9 @@
#include "gdb_assert.h"
#include "block.h"
#include "disasm.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
@@ -2065,6 +2068,16 @@
#else
error (_("long long not supported in printf"));
#endif
+ case ptr_arg:
+#ifdef HAVE_UINTPTR_T
+ {
+ void *val = (void *) (uintptr_t) value_as_address (val_args[i]);
+ printf_filtered (current_substring, val);
+ break;
+ }
+#else
+ error (_("pointer not supported in printf"));
+#endif
case int_arg:
{
int val = value_as_long (val_args[i]);
diff -u -r sources-clean/gdb/testsuite/gdb.base/display.exp sources-custom/gdb/testsuite/gdb.base/display.exp
--- sources-clean/gdb/testsuite/gdb.base/display.exp 2006-08-13 02:53:36.000000000 +0200
+++ sources-custom/gdb/testsuite/gdb.base/display.exp 2006-09-12 16:17:24.000000000 +0200
@@ -179,6 +179,8 @@
gdb_test "printf \"\"" ".*" "re-set term"
gdb_test "printf \"\\w\"" ".*Unrecognized escape character.*"
gdb_test "printf \"%d\" j" ".*Invalid argument syntax.*"
+# 0 or hex vs. dec printing may be platform dependent:
+gdb_test "printf \"<%p>\\n\", (void *)7" ".*7>.*"
# play with "print", too
#

View File

@ -11,7 +11,7 @@ Name: gdb
Version: 6.5
# The release always contains a leading reserved number, start it at 0.
Release: 7%{?dist}
Release: 8%{?dist}
License: GPL
Group: Development/Debuggers
@ -250,6 +250,9 @@ Patch189: gdb-6.5-opcodes-i386-nopmem.patch
# CVE-2006-4146
Patch190: gdb-6.5-dwarf-stack-overflow.patch
# Fix gdb printf command argument using "%p" (BZ 205551).
Patch191: gdb-6.5-bz205551-printf-p.patch
BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
BuildRequires: flex bison sharutils
@ -351,6 +354,7 @@ and printing their data.
%patch188 -p1
%patch189 -p1
%patch190 -p1
%patch191 -p1
# Change the version that gets printed at GDB startup, so it is RedHat
# specific.
@ -511,6 +515,9 @@ fi
# don't include the files in include, they are part of binutils
%changelog
* Mon Sep 11 2006 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.5-8
- Fix gdb printf command argument using "%p" (BZ 205551).
* Mon Sep 4 2006 Alexandre Oliva <aoliva@redhat.com> - 6.5-7
- Fix bug in patch for CVE-2006-4146. (BZ 203873, BZ 203880)