|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
689258 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
689258 |
Subject: gdb-rhbz795424-bitpos-21of25.patch
|
|
|
689258 |
|
|
|
689258 |
;; Fix `GDB cannot access struct member whose offset is larger than 256MB'
|
|
|
689258 |
;; (RH BZ 795424).
|
|
|
689258 |
;;=push
|
|
|
689258 |
|
|
|
689258 |
http://sourceware.org/ml/gdb-patches/2012-09/msg00632.html
|
|
|
689258 |
|
|
|
689258 |
--MP_/PnL6l3LUsXWpZ/olqawWlzb
|
|
|
689258 |
Content-Type: text/plain; charset=US-ASCII
|
|
|
689258 |
Content-Transfer-Encoding: 7bit
|
|
|
689258 |
Content-Disposition: inline
|
|
|
689258 |
|
|
|
689258 |
Hi,
|
|
|
689258 |
|
|
|
689258 |
This is part two of the bitpos expansion patch. This implements checks
|
|
|
689258 |
in some places in the code to ensure that a type size in ULONGEST is
|
|
|
689258 |
small enough to fit into host memory. Tested for regressions on x86_64
|
|
|
689258 |
Fedora 16.
|
|
|
689258 |
|
|
|
689258 |
Regards,
|
|
|
689258 |
Siddhesh
|
|
|
689258 |
|
|
|
689258 |
--MP_/PnL6l3LUsXWpZ/olqawWlzb
|
|
|
689258 |
Content-Type: text/plain
|
|
|
689258 |
Content-Transfer-Encoding: quoted-printable
|
|
|
689258 |
Content-Disposition: attachment; filename=ChangeLog-ensure_sizet
|
|
|
689258 |
|
|
|
689258 |
gdb/ChangeLog
|
|
|
689258 |
|
|
|
689258 |
* alpha-tdep.c (alpha_push_dummy_call) Check for underflow in
|
|
|
689258 |
SP.
|
|
|
689258 |
* cp-valprint (cp_print_value): Ensure BASECLASS fits into
|
|
|
689258 |
size_t.
|
|
|
689258 |
* dwarf2loc.c (read_pieced_value): Ensure that THIS_SIZE fits
|
|
|
689258 |
into size_t.
|
|
|
689258 |
(write_pieced_value): Likewise.
|
|
|
689258 |
* findcmd.c (parse_find_args): Ensure PATTERN_BUF_SIZE fits into
|
|
|
689258 |
size_t.
|
|
|
689258 |
* p-valprint (pascal_object_print_value): Ensure BASECLASS fits
|
|
|
689258 |
into size_t.
|
|
|
689258 |
* utils.c (ulongest_fits_host_or_error): New function to find if
|
|
|
689258 |
a ULONGEST number fits into size_t.
|
|
|
689258 |
* utils.h: Declare ulongest_fits_host_or_error.
|
|
|
689258 |
* valops.c (search_struct_method): Ensure BASECLASS fits into
|
|
|
689258 |
size_t.
|
|
|
689258 |
* value.c (allocate_value_lazy): Ensure TYPE fits into size_t.
|
|
|
689258 |
(allocate_value_contents): Likewise.
|
|
|
689258 |
(set_value_enclosing_type): Ensure NEW_ENCL_TYPE fits into
|
|
|
689258 |
size_t.
|
|
|
689258 |
* vax-tdep.c (vax_return_value): Ensure that TYPE fits into
|
|
|
689258 |
size_t.
|
|
|
689258 |
|
|
|
689258 |
--MP_/PnL6l3LUsXWpZ/olqawWlzb
|
|
|
689258 |
Content-Type: text/x-patch
|
|
|
689258 |
Content-Transfer-Encoding: 7bit
|
|
|
689258 |
Content-Disposition: attachment; filename=bitpos-ensure-size_t.patch
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
|
|
|
689258 |
--- a/gdb/alpha-tdep.c
|
|
|
689258 |
+++ b/gdb/alpha-tdep.c
|
|
|
689258 |
@@ -413,6 +413,13 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
|
|
689258 |
accumulate_size = 0;
|
|
|
689258 |
else
|
|
|
689258 |
accumulate_size -= sizeof(arg_reg_buffer);
|
|
|
689258 |
+
|
|
|
689258 |
+ /* Check for underflow. */
|
|
|
689258 |
+ if (sp - accumulate_size > sp)
|
|
|
689258 |
+ error (_("Insufficient memory in GDB host for arguments, "
|
|
|
689258 |
+ "need %s bytes, but less than %s bytes available."),
|
|
|
689258 |
+ plongest (accumulate_size), plongest (CORE_ADDR_MAX - sp));
|
|
|
689258 |
+
|
|
|
689258 |
sp -= accumulate_size;
|
|
|
689258 |
|
|
|
689258 |
/* Keep sp aligned to a multiple of 16 as the ABI requires. */
|
|
|
689258 |
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
|
|
|
689258 |
--- a/gdb/cp-valprint.c
|
|
|
689258 |
+++ b/gdb/cp-valprint.c
|
|
|
689258 |
@@ -529,6 +529,7 @@ cp_print_value (struct type *type, struct type *real_type,
|
|
|
689258 |
if ((boffset + offset) < 0
|
|
|
689258 |
|| (boffset + offset) >= TYPE_LENGTH (real_type))
|
|
|
689258 |
{
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (baseclass));
|
|
|
689258 |
gdb::byte_vector buf (TYPE_LENGTH (baseclass));
|
|
|
689258 |
|
|
|
689258 |
if (target_read_memory (address + boffset, buf.data (),
|
|
|
689258 |
diff --git a/gdb/defs.h b/gdb/defs.h
|
|
|
689258 |
--- a/gdb/defs.h
|
|
|
689258 |
+++ b/gdb/defs.h
|
|
|
689258 |
@@ -665,4 +665,6 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
|
|
|
689258 |
|
|
|
689258 |
#include "utils.h"
|
|
|
689258 |
|
|
|
689258 |
+extern void ulongest_fits_host_or_error (ULONGEST num);
|
|
|
689258 |
+
|
|
|
689258 |
#endif /* #ifndef DEFS_H */
|
|
|
689258 |
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
|
|
|
689258 |
--- a/gdb/p-valprint.c
|
|
|
689258 |
+++ b/gdb/p-valprint.c
|
|
|
689258 |
@@ -773,6 +773,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
|
|
|
689258 |
|
|
|
689258 |
if (boffset < 0 || boffset >= TYPE_LENGTH (type))
|
|
|
689258 |
{
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (baseclass));
|
|
|
689258 |
buf.resize (TYPE_LENGTH (baseclass));
|
|
|
689258 |
|
|
|
689258 |
base_valaddr = buf.data ();
|
|
|
689258 |
diff --git a/gdb/utils.c b/gdb/utils.c
|
|
|
689258 |
--- a/gdb/utils.c
|
|
|
689258 |
+++ b/gdb/utils.c
|
|
|
689258 |
@@ -2834,6 +2834,17 @@ string_to_core_addr (const char *my_string)
|
|
|
689258 |
return addr;
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
+/* Ensure that the input NUM is not larger than the maximum capacity of the
|
|
|
689258 |
+ host system. We choose SIZE_MAX / 8 as a conservative estimate of the size
|
|
|
689258 |
+ of a resource that a system may allocate. */
|
|
|
689258 |
+void
|
|
|
689258 |
+ulongest_fits_host_or_error (ULONGEST num)
|
|
|
689258 |
+{
|
|
|
689258 |
+ if (num > SIZE_MAX / 8)
|
|
|
689258 |
+ error (_("Insufficient memory in host GDB for object of size %s bytes, "
|
|
|
689258 |
+ "maximum allowed %s bytes."), pulongest (num),
|
|
|
689258 |
+ pulongest (SIZE_MAX / 8));
|
|
|
689258 |
+}
|
|
|
689258 |
#if GDB_SELF_TEST
|
|
|
689258 |
|
|
|
689258 |
static void
|
|
|
689258 |
diff --git a/gdb/valops.c b/gdb/valops.c
|
|
|
689258 |
--- a/gdb/valops.c
|
|
|
689258 |
+++ b/gdb/valops.c
|
|
|
689258 |
@@ -2088,6 +2088,7 @@ search_struct_method (const char *name, struct value **arg1p,
|
|
|
689258 |
{
|
|
|
689258 |
CORE_ADDR address;
|
|
|
689258 |
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (baseclass));
|
|
|
689258 |
gdb::byte_vector tmp (TYPE_LENGTH (baseclass));
|
|
|
689258 |
address = value_address (*arg1p);
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/value.c b/gdb/value.c
|
|
|
689258 |
--- a/gdb/value.c
|
|
|
689258 |
+++ b/gdb/value.c
|
|
|
689258 |
@@ -933,6 +933,7 @@ allocate_value_lazy (struct type *type)
|
|
|
689258 |
description correctly. */
|
|
|
689258 |
check_typedef (type);
|
|
|
689258 |
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (type));
|
|
|
689258 |
val = new struct value (type);
|
|
|
689258 |
|
|
|
689258 |
/* Values start out on the all_values chain. */
|
|
|
689258 |
@@ -1015,6 +1016,8 @@ check_type_length_before_alloc (const struct type *type)
|
|
|
689258 |
static void
|
|
|
689258 |
allocate_value_contents (struct value *val)
|
|
|
689258 |
{
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (val->enclosing_type));
|
|
|
689258 |
+
|
|
|
689258 |
if (!val->contents)
|
|
|
689258 |
{
|
|
|
689258 |
check_type_length_before_alloc (val->enclosing_type);
|
|
|
689258 |
@@ -2876,6 +2879,7 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type)
|
|
|
689258 |
if (TYPE_LENGTH (new_encl_type) > TYPE_LENGTH (value_enclosing_type (val)))
|
|
|
689258 |
{
|
|
|
689258 |
check_type_length_before_alloc (new_encl_type);
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (new_encl_type));
|
|
|
689258 |
val->contents
|
|
|
689258 |
.reset ((gdb_byte *) xrealloc (val->contents.release (),
|
|
|
689258 |
TYPE_LENGTH (new_encl_type)));
|
|
|
689258 |
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
|
|
|
689258 |
--- a/gdb/vax-tdep.c
|
|
|
689258 |
+++ b/gdb/vax-tdep.c
|
|
|
689258 |
@@ -218,6 +218,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
|
|
|
689258 |
ULONGEST addr;
|
|
|
689258 |
|
|
|
689258 |
regcache_raw_read_unsigned (regcache, VAX_R0_REGNUM, &addr);
|
|
|
689258 |
+ ulongest_fits_host_or_error (TYPE_LENGTH (type));
|
|
|
689258 |
read_memory (addr, readbuf, len);
|
|
|
689258 |
}
|
|
|
689258 |
|