Repository navigation
Conversation
google#4010 capped number_of_leading_zeros in PhoneNumberUtil.java and phonenumberutil.cc. The same logic has three more copies that were left out: - ShortNumberInfo.java has its own getNationalSignificantNumber(). It also lacks the "> 0" check, so -1 throws NegativeArraySizeException, and large values throw OutOfMemoryError. - phonenumberutil.js and shortnumberinfo.js build the zeros with Array(n + 1).join('0'), which throws RangeError for large values. Use the same cap of 10 in all three. The C++ ShortNumberInfo goes through PhoneNumberUtil, so it is already covered. Bug: https://issuetracker.google.com/issues/523402884
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#4010 capped
number_of_leading_zerosinPhoneNumberUtil.javaandphonenumberutil.cc. The same logic has three more copies that were left out, so this applies the same cap of 10 to them.ShortNumberInfo.javahas its owngetNationalSignificantNumber(). It also lacks the> 0check thatPhoneNumberUtil.javahas.-1:NegativeArraySizeException500000000with-Xmx512m:OutOfMemoryError: Java heap spaceInteger.MAX_VALUE:OutOfMemoryError: Requested array size exceeds VM limitphonenumberutil.jsandshortnumberinfo.jsbuild the zeros withArray(n + 1).join('0').2147483647throwsRangeError: Invalid string length.The C++
ShortNumberInfogoes throughPhoneNumberUtil::GetNationalSignificantNumber, so it's already covered and there's no C++ change here.Bug: https://issuetracker.google.com/issues/523402884 (same issue as #4010)
Ran
ShortNumberInfoTestandPhonenumberTestwith javac and JUnit on JDK 17, not through Maven.PhoneNumberUtilTestwasn't run because it needs Mockito, andPhoneNumberUtil.javaisn't touched. The JS tests inphonenumberutil_test.jsandshortnumberinfo_test.jsran in node with google-closure-library rather than in a browser through the.htmlrunners.