Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3/gdb/dist/gdb Validate register number before f...
details: https://anonhg.NetBSD.org/src/rev/ea77061c2a30
branches: trunk
changeset: 459820:ea77061c2a30
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 26 20:11:10 2019 +0000
description:
Validate register number before fetching/storing it (Gopikrishnan Sidhardhan)
diffstat:
external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diffs (58 lines):
diff -r 6e08804962fa -r ea77061c2a30 external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Thu Sep 26 18:45:00 2019 +0000
+++ b/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Thu Sep 26 20:11:10 2019 +0000
@@ -49,6 +49,24 @@
static arm_nbsd_nat_target the_arm_nbsd_nat_target;
+/* Determine if PT_GETREGS fetches REGNUM. */
+
+static bool
+getregs_supplies (int regnum)
+{
+ return ((regnum >= ARM_A1_REGNUM && regnum <= ARM_PC_REGNUM)
+ || regnum == ARM_PS_REGNUM);
+}
+
+/* Determine if PT_GETFPREGS fetches REGNUM. */
+
+static bool
+getfpregs_supplies (int regnum)
+{
+ return ((regnum >= ARM_D0_REGNUM && regnum <= ARM_D31_REGNUM)
+ || regnum == ARM_FPSCR_REGNUM);
+}
+
extern int arm_apcs_32;
#define FPSCR(r) ((char *) &(r)->fpr_vfp.vfp_fpscr)
@@ -256,10 +274,12 @@
{
if (regno >= 0)
{
- if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
+ if (getregs_supplies (regno))
+ fetch_register (regcache, regno);
+ else if (getfpregs_supplies (regno))
fetch_fp_register (regcache, regno);
else
- fetch_register (regcache, regno);
+ warning (_("unable to fetch register %d"), regno);
}
else
{
@@ -442,10 +462,12 @@
{
if (regno >= 0)
{
- if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
+ if (getregs_supplies (regno))
+ store_register (regcache, regno);
+ else if (getfpregs_supplies (regno))
store_fp_register (regcache, regno);
else
- store_register (regcache, regno);
+ warning (_("unable to store register %d"), regno);
}
else
{
Home |
Main Index |
Thread Index |
Old Index