Skip to content

fix(grammars): widen uint8_t loop counters in objectscript scanner (CodeQL #69-#72)#1136

Merged
DeusData merged 1 commit into
mainfrom
fix/codeql-objectscript-wider-type
Jul 16, 2026
Merged

fix(grammars): widen uint8_t loop counters in objectscript scanner (CodeQL #69-#72)#1136
DeusData merged 1 commit into
mainfrom
fix/codeql-objectscript-wider-type

Conversation

@DeusData

Copy link
Copy Markdown
Owner

What

Clears the 4 open CodeQL cpp/comparison-with-wider-type alerts (#69, #70, #71, #72, all high severity) on main.

Where

The vendored ObjectScript scanner objectscript_common.h (identical in both the objectscript_routine and objectscript_udl grammar copies) has two loops that compare a uint8_t counter against an int length:

  • the reverse_marker scan (while (i < reverse_marker_len ...))
  • the html_marker_buffer reversal (for (uint8_t i = 0; i < html_marker_buffer_len; i++))

Assessment

Unreachable in practice, but fixed for cleanliness. Both lengths are hard-bounded by MARKER_BUFFER_MAX_LEN = 30, so the uint8_t counter can never wrap to 0 and the flagged infinite loop cannot occur. The finding is a false positive at these call sites — CodeQL flags the pattern without the buffer-cap context. Widening the two counters to int removes the pattern and clears the gate; the change is provably behavior-neutral (int holds every uint8_t value, and the length is always ≤ 30).

Vendored-code note

These are byte-for-byte-upstream InterSystems grammar files. The widening is recorded as a local modification in internal/cbm/vendored/grammars/MANIFEST.md so it is re-applied on the next re-vendor (or upstreamed at intersystems/tree-sitter-objectscript). No other changes to the vendored scanner.

Build passes. There's no runtime regression test — the guard is CodeQL itself going green (the fix is a static type widening on an unreachable path).

…odeQL)

CodeQL cpp/comparison-with-wider-type (4 high-severity alerts, #69-#72) flagged
two loops in the vendored ObjectScript scanner (objectscript_common.h, in both
the _routine and _udl grammar copies) where a uint8_t counter is compared
against an int length: the reverse_marker scan and the html_marker_buffer
reversal. Both lengths are hard-bounded by MARKER_BUFFER_MAX_LEN (30), so the
uint8_t counter can never wrap and the flagged infinite loop is unreachable in
practice — but widening the counters to int removes the pattern and clears the
gate. Provably behavior-neutral (int holds every uint8_t value; length <= 30).

Recorded as a local modification in the vendored grammar MANIFEST so it is
re-applied on the next re-vendor.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData
DeusData enabled auto-merge July 16, 2026 16:35
@DeusData
DeusData merged commit 7235a4d into main Jul 16, 2026
36 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant