Skip to content
Permalink
Browse files

regcomp.c: Convert some strchr to memchr

This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.

(cherry picked from commit 43b2f4e)
  • Loading branch information
khwilliamson authored and steve-m-hay committed Mar 25, 2017
1 parent 5dfd984 commit c1c28ce6ba90ee05aa96b11ad551a6063680f3b9
Showing with 7 additions and 4 deletions.
  1. +7 −4 regcomp.c
@@ -12023,7 +12023,8 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,

RExC_parse++; /* Skip past the '{' */

if (! (endbrace = strchr(RExC_parse, '}'))) { /* no trailing brace */
endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
if (! endbrace) { /* no trailing brace */
vFAIL2("Missing right brace on \\%c{}", 'N');
}
else if(!(endbrace == RExC_parse /* nothing between the {} */
@@ -12692,9 +12693,11 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
else {
STRLEN length;
char name = *RExC_parse;
char * endbrace;
char * endbrace = NULL;
RExC_parse += 2;
endbrace = strchr(RExC_parse, '}');
if (RExC_parse < RExC_end) {
endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
}

if (! endbrace) {
vFAIL2("Missing right brace on \\%c{}", name);
vFAIL2("Empty \\%c", (U8)value);
if (*RExC_parse == '{') {
const U8 c = (U8)value;
e = strchr(RExC_parse, '}');
e = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
if (!e) {
RExC_parse++;
vFAIL2("Missing right brace on \\%c{}", c);

0 comments on commit c1c28ce

Please sign in to comment.
You can’t perform that action at this time.