Skip to content

guard int32/uint32 map key narrowing in qualifyInternal#1337

Open
alhudz wants to merge 2 commits into
cel-expr:masterfrom
alhudz:narrow-map-key-index
Open

guard int32/uint32 map key narrowing in qualifyInternal#1337
alhudz wants to merge 2 commits into
cel-expr:masterfrom
alhudz:narrow-map-key-index

Conversation

@alhudz

@alhudz alhudz commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Repro: indexing a native map[int32]any with a key outside the int32 range, e.g. m[4294967296] where m == {0: "x"}, returns "x" instead of a no-such-key error. Same for map[uint32]any.
Cause: intQualifier.qualifyInternal and uintQualifier.qualifyInternal cast the int64/uint64 index to int32/uint32 before the lookup, so 4294967296 wraps to 0 and collides with the entry stored at key 0.
Fix: only perform the narrowed lookup when the index round-trips through the key type (int64(int32(i)) == i), otherwise fall through to the existing missing-key path.

Comment thread interpreter/attributes_test.go Outdated
@TristonianJones

Copy link
Copy Markdown
Collaborator

/gcbrun

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.

2 participants