Skip to content

Backport #3810: bounds check iChanID before array access (release/3_12) - #3840

Open
mcfnord wants to merge 2 commits into
jamulussoftware:release/3_12from
mcfnord:backport-3810-release-3_12
Open

Backport #3810: bounds check iChanID before array access (release/3_12)#3840
mcfnord wants to merge 2 commits into
jamulussoftware:release/3_12from
mcfnord:backport-3810-release-3_12

Conversation

@mcfnord

@mcfnord mcfnord commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

MY LLM WROTE:

Backports #3810's fix to release/3_12. A straight cherry-pick of 562cfd84 doesn't apply here: it calls MathUtils::InRange, which doesn't exist on this branch — it was added by #3741 and only reached its current half-open-interval semantics via #3812, neither of which is on release/3_12. Rather than backport that dependency chain too, this inlines the equivalent bounds check directly, with the same effect: iChanID arrives off the wire as an unvalidated value and this branch's ApplyNewConClientList had no check before indexing a 150-entry stack array with it.

Verified: -fsyntax-only clean, clang-format unchanged, full client build (qmake && make) compiles and links with no errors. Only src/audiomixerboard.cpp touched.

Fixes the same issue as #3810, for release/3_12.

@dingodoppelt dingodoppelt added the AI AI generated or potentially AI generated label Jul 28, 2026

@ann0see ann0see left a comment

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 don't like this inlining: we should ship the same code as on main.

@mcfnord

mcfnord commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

MY LLM WROTE:

@ann0see Fair — pushed 57525a2b to ship the same code as main instead. Rather than inline the check, I backported just MathUtils::InRange (the template method itself, half-open-interval semantics from #3812) into class MathUtils in util.h. release/3_12's MathUtils class already exists, so this is a single self-contained method addition — no dependency on the rest of #3741/#3812's chat refactor. audiomixerboard.cpp's ApplyNewConClientList now calls MathUtils::InRange<int>( iChanID, 0, MAX_NUM_CHANNELS ), byte-for-byte identical to main's 562cfd84.

Verified: clang-format-14 --dry-run --Werror clean, full client build (qmake && make) compiles and links with no errors/warnings.

@pljones

pljones commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

OK, that's small enough.

@pljones pljones added bug Something isn't working refactoring Non-behavioural changes, Code cleanup labels Jul 28, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Jul 28, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Waiting externally in Tracking Jul 28, 2026
@pljones pljones added this to the Release 3.12.4 milestone Jul 28, 2026
@ann0see

ann0see commented Jul 28, 2026

Copy link
Copy Markdown
Member

I still prefer the exact same commits cherry picked.

@dingodoppelt dingodoppelt left a comment

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'd prefer cherry-picking the original commits. We didn't squash on merge so there are a few which could be squashed only for this backport.

jrd and others added 2 commits July 29, 2026 00:57
…, jamulussoftware#3812)

release/3_12 needs MathUtils::InRange for the jamulussoftware#3810 bounds-check
backport, but jamulussoftware#3741 introduced it as part of a much larger server
chat-handling refactor (new CServer::SendChatTextToConChannel /
SendChatTextToAllConChannels methods) that this branch does not
have and is out of scope for a bug-fix backport.

This squashes just the src/util.h hunks from the six main commits
that shaped MathUtils::InRange into its current form, in order,
omitting every hunk outside util.h:

  562d6c6 Refactor server chat handling by extracting methods. Added
           range check method to MathUtils (jamulussoftware#3741)
  4f9a532 Clarify comment (jamulussoftware#3741)
  6d305cb Check for half open interval in MathUtils::InRange (jamulussoftware#3812)
  65513e5 Update src/util.h (jamulussoftware#3812)
  fe98b1a Fix style (jamulussoftware#3812)

Result is byte-for-byte identical to MathUtils::InRange on main.
Switch bounds check to use MathUtils

Fix channel ID range check in audiomixerboard

(cherry picked from commit 562cfd8)
@mcfnord
mcfnord force-pushed the backport-3810-release-3_12 branch from 57525a2 to f018042 Compare July 29, 2026 01:07
@mcfnord

mcfnord commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

MY LLM WROTE:

Force-pushed with actual cherry-picks instead of the hand-written equivalent.

29a13e49 squashes just the src/util.h hunks from the six main commits that shaped MathUtils::InRange into its current form — #3741's 562d6c66 + 4f9a532a, then #3812's 6d305cb7 + 65513e5b + fe98b1ad — applied in that order. I left out their server.cpp/server.h hunks: those belong to #3741's SendChatTextToConChannel/SendChatTextToAllConChannels refactor, which release/3_12 doesn't have and which is out of scope for a bounds-check backport. Squashing was necessary because several of those six commits are one-line follow-ups to each other (comment wording, style) — cherry-picking them individually would have produced intermediate states that don't compile standalone once the chat-refactor hunks are dropped.

f0180425 is git cherry-pick -x 562cfd84 unmodified — same commit, same author, (cherry picked from commit ...) trailer intact.

Net result is identical to the previous push, plus one line I'd missed: the // Returns true if value is in [lower, upper)... comment above InRange, which main has and my earlier hand-typed version didn't. Confirmed byte-for-byte against MathUtils::InRange on main.

Verified: clang-format-14 --dry-run --Werror clean, full client build (qmake && make) compiles and links Jamulus with no errors/warnings.

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 refactoring Non-behavioural changes, Code cleanup

Projects

Status: Waiting externally

Development

Successfully merging this pull request may close these issues.

4 participants