Skip to content

Commit 3de5f1a

Browse files
committed
ICU-23305 Fix int64_t overflow in doParse
1 parent 9f1c574 commit 3de5f1a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

icu4c/source/i18n/nfsubs.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// © 2016 and later: Unicode, Inc. and others.
1+
/)/ © 2016 and later: Unicode, Inc. and others.
22
// License & terms of use: http://www.unicode.org/copyright.html
33
/*
44
******************************************************************************
@@ -1343,10 +1343,18 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
13431343
int64_t n = result.getLong(status); // force conversion!
13441344
int64_t d = 1;
13451345
while (d <= n) {
1346+
if (d > U_INT64_MAX / 10) {
1347+
// Will cause int64_t overflow
1348+
return false;
1349+
}
13461350
d *= 10;
13471351
}
13481352
// now add the zeros
13491353
while (zeroCount > 0) {
1354+
if (d > U_INT64_MAX / 10) {
1355+
// Will cause int64_t overflow
1356+
return false;
1357+
}
13501358
d *= 10;
13511359
--zeroCount;
13521360
}

0 commit comments

Comments
 (0)