From adc2d0c9de764f1cb892860df8ecc93dc8909b39 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Mon, 21 Apr 2014 21:43:12 -0400 Subject: Fix for Coverity perl5 CID 29034: Out-of-bounds read (OVERRUN) overrun-local: Overrunning array PL_reg_intflags name of 14 8-byte elements at element index 31 (byte offset 248) using index bit (which evaluates to 31). Needed compile-time limits for the PL_reg_intflags_name so that the bit loop doesn't waltz off past the array. Could not use C_ARRAY_LENGTH because the size of name array is not visible during compile time (only const char*[] is), so modified regcomp.pl to generate the size, made it visible only under DEBUGGING. Did extflags analogously even though its size currently exactly 32 already. The sizeof(flags)*8 is extra paranoia for ILP64. --- regcomp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index 0238af9e04..920f7cb2ff 100644 --- a/regcomp.c +++ b/regcomp.c @@ -15365,7 +15365,9 @@ S_regdump_intflags(pTHX_ const char *lead, const U32 flags) int bit; int set=0; - for (bit=0; bit<32; bit++) { + ASSUME(REG_INTFLAGS_NAME_SIZE <= sizeof(flags)*8); + + for (bit=0; bit