Skip to content

add bounds check for country code table - #3811

Merged
ann0see merged 1 commit into
jamulussoftware:mainfrom
ann0see:fix/next
Jul 21, 2026
Merged

ann0see merged 1 commit into
jamulussoftware:mainfrom
ann0see:fix/next

Conversation

@ann0see

@ann0see ann0see commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Short description of changes

Adds bounds check for qt6 country code conversion (also found like #3810 )

CHANGELOG: Add bounds checking for country code lookup

Context: Fixes an issue?

/

Does this change need documentation? What needs to be documented and how?

No

Status of this Pull Request

Ready for review (didn't analyze this one deeply). The style follows isCountryCodeSupported. Alternatively, we could probably just call IsCountryCode supported as guard?

What is missing until this pull request can be merged?

Review, analysis.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want (as in - it compiles with qt6 and seemed to show countries correctly - but not 100% sure)
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

Comment thread src/util.cpp
// Qt6 changed those IDs, so we have to convert back:
if ( iCountryCode >= qt6CountryToWireFormatLen )
{
return QLocale::AnyCountry;

Copy link
Copy Markdown
Member Author

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?

Copy link
Copy Markdown
Member

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.

Comment thread src/util.cpp

if ( iIdx >= qt6CountryToWireFormatLen )
{
return 0;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to return...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct, because it is the Qt5 value for QLocale::AnyCountry, which is sent on the wire if a country is explicitly not defined.

If a server does not specify --serverinfo, or leaves the country code blank, such as --serverinfo 'My Server;London;', then it gets replaced by the country of the system locale. If the server operator doesn't want a country to show (and there are a small number like that), they need explicitly to give a code of 0: --serverinfo 'My Server;;0'

@ann0see
ann0see requested a review from softins July 20, 2026 13:51
@ann0see ann0see added the bug Something isn't working label Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Jul 20, 2026
@ann0see ann0see added this to the 3.12.3 milestone Jul 20, 2026
@ann0see ann0see added the AI AI generated or potentially AI generated label Jul 21, 2026
@pljones

pljones commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Again with this, merge to main initially, then PR onto release/3_12.

@pljones pljones added the backport_required A change to main that needs fix on an existing release. label Jul 21, 2026
@ann0see

ann0see commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

Are you sure that you do not want a git cherry pick with one PR including all or most of the bugfixes?

@pljones pljones moved this from Triage to Waiting on Team in Tracking Jul 21, 2026
@pljones

pljones commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Are you sure that you do not want a git cherry pick with one PR including all or most of the bugfixes?

I'd rather not a single PR. Group related commits cherry-picked over into single PRs, yes but I'd still like a structured history for things like git log --graph r3_12_2..r3_12_3.

@ann0see
ann0see merged commit 01a85af into jamulussoftware:main Jul 21, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting on Team to Done in Tracking Jul 21, 2026
@pljones pljones removed the backport_required A change to main that needs fix on an existing release. label Jul 26, 2026
@pljones

pljones commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Backported to release/3_12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI generated or potentially AI generated bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants