]> granicus.if.org Git - onig/commitdiff
regenc: onigenc_strlen check for n overflow
authorRuslan Kuprieiev <kupruser@gmail.com>
Thu, 15 Jun 2017 23:34:38 +0000 (02:34 +0300)
committerRuslan Kuprieiev <kupruser@gmail.com>
Sat, 24 Jun 2017 01:52:37 +0000 (04:52 +0300)
On 64bit systems maximum theoretical length 'p-end' can
exceed INT_MAX, causing 'n' to overflow.

Id: 48

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
src/regenc.c

index 554a622382c9b7f03094a5b91389ff090cebf379..c1784577ea513341b9264083e3b6b5c893056594 100644 (file)
@@ -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;
 }