diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2022-12-09 14:19:31 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2022-12-12 16:21:31 +0900 |
commit | be18b60c335ea0d557717470826a489939316192 (patch) | |
tree | 36a6e89763f92b300092c9ae7ea76bcea71cda36 /regenc.h | |
parent | e1f42844a0b2a4dcf4c7338c41ef92f1b45393d8 (diff) |
Prevent potential buffer overflow on enclen
Follow up of 1d2d25dcadda0764f303183ac091d0c87b432566
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6903
Diffstat (limited to 'regenc.h')
-rw-r--r-- | regenc.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -91,7 +91,7 @@ typedef struct { #define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val) -#define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? enc->min_enc_len : ONIGENC_MBC_ENC_LEN(enc,p,e)) +#define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? (p < e ? enc->min_enc_len : 0) : ONIGENC_MBC_ENC_LEN(enc,p,e)) /* character types bit flag */ #define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE) |