nyaruka / phonenumbers

GoLang port of Google's libphonenumber library
MIT License
1.25k stars 148 forks source link

Fix slice out of bounds in GetTimezonesForPrefix #119

Closed rreuvekamp closed 2 years ago

rreuvekamp commented 2 years ago

When the length of the number supplied to GetTimezonesForPrefix was less than timezoneMap.MaxLength, the function call would result in a panic because of a slice index out of bounds.

This happened with +31112 for instance, which is a valid short number, and +6837000 which is a valid regular number (according to IsValidNumber).

This patch will make sure the matching length cannot be longer than the length of the given number.

rowanseymour commented 2 years ago

@rreuvekamp if you merge main it should fix the coverage upload error

rreuvekamp commented 2 years ago

Hi Rowan,

Thanks for the quick reply! I've applied the changes.

rreuvekamp commented 2 years ago

Not sure why Github says I "removed request for norkans7", but thanks for the review 👍