This is the mail archive of the
mailing list for the GDB project.
[PATCH] [PR corefiles/17808] i386: Fix internal error when prstatus in core file is too big
- From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: jan dot kratochvil at redhat dot com
- Date: Thu, 08 Jan 2015 17:16:20 +0100
- Subject: [PATCH] [PR corefiles/17808] i386: Fix internal error when prstatus in core file is too big
- Authentication-results: sourceware.org; auth=none
As reported in PR 17808, a test case with a forged (invalid) core file
can crash GDB with an assertion failure. In that particular case the
prstatus of an i386 core file looks like that from an AMD64 core file,
i.e., it is larger than GDB would expect.
The patch replaces the assertion by a warning and skips the invalid
core file register section. In this way it is guaranteed that no
bogus register values are read from the badly formatted section.
Note that this behavior deviates from the default policy: In general, if
some future kernel adds new registers to a register set, then a GDB
unaware of this extension would read the known subset and just ignore
the unknown bytes.
* i386-tdep.c (i386_supply_gregset): Instead of yielding an
internal error on unexpected input buffer size, ignore the data
and emit a warning.
gdb/i386-tdep.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 7d174c4..d02aaf2 100644
@@ -3727,7 +3727,12 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
const gdb_byte *regs = gregs;
- gdb_assert (len == tdep->sizeof_gregset);
+ if (len != tdep->sizeof_gregset)
+ /* Buffer has unknown size: assume wrong format. */
+ warning (_("Bad size of general register section"));
for (i = 0; i < tdep->gregset_num_regs; i++)