[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] [PATCH] coredump: simplify bad regnum checks a lit
From: |
Berat, Frederic (ADITG/SW1) |
Subject: |
Re: [Libunwind-devel] [PATCH] coredump: simplify bad regnum checks a little |
Date: |
Tue, 14 Feb 2017 07:29:19 +0000 |
Looking at the code snippet, there could also be a kind of "UNW_LAST_REG" value
defined in architecture specific code. The "port me" complain would then be if
this value is not defined.
Best regards
Frederic Berat
Software Group I (ADITG/SW1)
Tel. +49 5121 49 6935
> -----Original Message-----
> From: Libunwind-devel [mailto:libunwind-devel-bounces+fberat=de.adit-
> address@hidden On Behalf Of Mike Frysinger
> Sent: Dienstag, 14. Februar 2017 03:33
> To: address@hidden
> Subject: [Libunwind-devel] [PATCH] coredump: simplify bad regnum checks a
> little
>
> We always want to reject negative regnums since we use it as an index, so
> make it a common check at the top for all arches.
> ---
> src/coredump/_UCD_access_reg_linux.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/src/coredump/_UCD_access_reg_linux.c
> b/src/coredump/_UCD_access_reg_linux.c
> index 4b5994fad438..208d8d27b658 100644
> --- a/src/coredump/_UCD_access_reg_linux.c
> +++ b/src/coredump/_UCD_access_reg_linux.c
> @@ -39,17 +39,20 @@ _UCD_access_reg (unw_addr_space_t as,
> return -UNW_EINVAL;
> }
>
> + if (regnum < 0)
> + goto badreg;
> +
> #if defined(UNW_TARGET_AARCH64)
> - if (regnum < 0 || regnum >= UNW_AARCH64_FPCR)
> + if (regnum >= UNW_AARCH64_FPCR)
> goto badreg;
> #elif defined(UNW_TARGET_ARM)
> - if (regnum < 0 || regnum >= 16)
> + if (regnum >= 16)
> goto badreg;
> #elif defined(UNW_TARGET_SH)
> - if (regnum < 0 || regnum > UNW_SH_PR)
> + if (regnum > UNW_SH_PR)
> goto badreg;
> #elif defined(UNW_TARGET_TILEGX)
> - if (regnum < 0 || regnum > UNW_TILEGX_CFA)
> + if (regnum > UNW_TILEGX_CFA)
> goto badreg;
> #else
> #if defined(UNW_TARGET_MIPS)
> @@ -120,7 +123,7 @@ _UCD_access_reg (unw_addr_space_t as, #error
> Port me #endif
>
> - if (regnum < 0 || regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs))
> + if (regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs))
> goto badreg;
>
> regnum = remap_regs[regnum];
> --
> 2.11.0
>
>
> _______________________________________________
> Libunwind-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/libunwind-devel