-
Notifications
You must be signed in to change notification settings - Fork 245
add bounds check for country code table #3811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1369,6 +1369,10 @@ QLocale::Country CLocale::WireFormatCountryCodeToQtCountry ( unsigned short iCou | |
| #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) | ||
| // The Jamulus protocol wire format gives us Qt5 country IDs. | ||
| // Qt6 changed those IDs, so we have to convert back: | ||
| if ( iCountryCode >= qt6CountryToWireFormatLen ) | ||
| { | ||
| return QLocale::AnyCountry; | ||
| } | ||
| return (QLocale::Country) wireFormatToQt6Table[iCountryCode]; | ||
| #else | ||
| return (QLocale::Country) iCountryCode; | ||
|
|
@@ -1380,7 +1384,13 @@ unsigned short CLocale::QtCountryToWireFormatCountryCode ( const QLocale::Countr | |
| #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) | ||
| // The Jamulus protocol wire format expects Qt5 country IDs. | ||
| // Qt6 changed those IDs, so we have to convert back: | ||
| return qt6CountryToWireFormat[(unsigned short) eCountry]; | ||
| const unsigned short iIdx = static_cast<unsigned short> ( eCountry ); | ||
|
|
||
| if ( iIdx >= qt6CountryToWireFormatLen ) | ||
| { | ||
| return 0; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what to return...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is correct, because it is the Qt5 value for If a server does not specify |
||
| } | ||
| return qt6CountryToWireFormat[iIdx]; | ||
| #else | ||
| return (unsigned short) eCountry; | ||
| #endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we return otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't seem to exist any better alternative than this.