Skip to content
Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Nov 6, 2017
1 parent aea1585 commit 43b2f4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions regcomp.c
Expand Up @@ -12056,7 +12056,7 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,

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

endbrace = strchr(RExC_parse, '}');
endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
if (! endbrace) { /* no trailing brace */
vFAIL2("Missing right brace on \\%c{}", 'N');
}
Expand Down Expand Up @@ -12773,9 +12773,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);
Expand Down Expand Up @@ -16312,7 +16314,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
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);
Expand Down

0 comments on commit 43b2f4e

Please sign in to comment.