Module Name: src
Committed By: christos
Date: Thu Sep 26 20:11:10 UTC 2019
Modified Files:
src/external/gpl3/gdb/dist/gdb: arm-nbsd-nat.c
Log Message:
Validate register number before fetching/storing it (Gopikrishnan Sidhardhan)
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c
diff -u src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.12 src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.13
--- src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.12 Sat Aug 31 16:16:25 2019
+++ src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Thu Sep 26 16:11:10 2019
@@ -49,6 +49,24 @@ public:
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 @@ arm_nbsd_nat_target::fetch_registers (st
{
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 @@ arm_nbsd_nat_target::store_registers (st
{
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
{