From: K.Kosako Date: Tue, 9 Jul 2019 08:32:37 +0000 (+0900) Subject: clear buf tail after raw byte parsing X-Git-Tag: v6.9.3~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c9091ec292d0d834b920d231bb543cc34845a8f;p=onig clear buf tail after raw byte parsing --- diff --git a/src/regparse.c b/src/regparse.c index f1deea3..4ccfde5 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -6301,10 +6301,11 @@ parse_char_class(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env) case TK_RAW_BYTE: /* tok->base != 0 : octal or hexadec. */ if (! ONIGENC_IS_SINGLEBYTE(env->enc) && tok->base != 0) { + int i, j; UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN]; UChar* bufe = buf + ONIGENC_CODE_TO_MBC_MAXLEN; UChar* psave = p; - int i, base = tok->base; + int base = tok->base; buf[0] = tok->u.c; for (i = 1; i < ONIGENC_MBC_MAXLEN(env->enc); i++) { @@ -6322,6 +6323,9 @@ parse_char_class(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env) goto err; } + /* clear buf tail */ + for (j = i; j < ONIGENC_CODE_TO_MBC_MAXLEN; j++) buf[j] = '\0'; + len = enclen(env->enc, buf); if (i < len) { r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;