From cd13b57b5f2fa2f028ac9927f22e0e26112f23a3 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 16 Jun 2017 02:34:38 +0300 Subject: [PATCH] regenc: onigenc_strlen check for n overflow On 64bit systems maximum theoretical length 'p-end' can exceed INT_MAX, causing 'n' to overflow. Id: 48 Signed-off-by: Ruslan Kuprieiev --- src/regenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/regenc.c b/src/regenc.c index 554a622..c178457 100644 --- a/src/regenc.c +++ b/src/regenc.c @@ -140,7 +140,8 @@ onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end) while (q < end) { q += ONIGENC_MBC_ENC_LEN(enc, q); - n++; + if (n < INT_MAX) + n++; } return n; } -- 2.40.0