Fix another integer overflow in CFGAS_StringFormatter::ParseNum()
And the fuzzer found another corner case.
Bug: chromium:947188
Change-Id: I0ec5fb062882fb92686e9411d22e5880a8373982
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52654
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fgas/crt/cfgas_stringformatter.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp
index ab2dde8..02ace49 100644
--- a/xfa/fgas/crt/cfgas_stringformatter.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -1420,9 +1420,10 @@
while (cc < spSrcNum.size()) {
if (!FXSYS_IsDecimalDigit(spSrcNum[cc]))
break;
- if (iExponent > std::numeric_limits<int>::max() / 10)
+ int digit = FXSYS_DecimalCharToInt(spSrcNum[cc]);
+ if (iExponent > (std::numeric_limits<int>::max() - digit) / 10)
return false;
- iExponent = iExponent * 10 + FXSYS_DecimalCharToInt(spSrcNum[cc]);
+ iExponent = iExponent * 10 + digit;
cc++;
}
iExponent = bExpSign ? -iExponent : iExponent;