Skip to content

Fix ActionRecord payload setter: use || instead of && - #29

Merged
Harry-Chen merged 1 commit into
nfcim:masterfrom
klaasdannen:fix/action-record-validation
Mar 13, 2026
Merged

Harry-Chen merged 1 commit into
nfcim:masterfrom
klaasdannen:fix/action-record-validation

Conversation

@klaasdannen

Copy link
Copy Markdown
Contributor

Summary

  • The range check actionIndex >= Action.values.length && actionIndex < 0 is always false (no integer can satisfy both conditions simultaneously)
  • Invalid action indices bypass validation and cause an out-of-bounds RangeError on Action.values[actionIndex]
  • Changed && to || so the check correctly rejects values outside [0, Action.values.length)

Test plan

  • Existing Smart Poster tests pass
  • Decoding an NDEF message with an invalid action byte (e.g., 0xFF) now throws RangeError from the guard, not from list access

The condition `actionIndex >= Action.values.length && actionIndex < 0`
is always false since no value can be both >= length and < 0 at the
same time. This means invalid action indices are never caught and
would cause an out-of-bounds access on the next line.
@Harry-Chen
Harry-Chen merged commit 71c0412 into nfcim:master Mar 13, 2026
2 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.

2 participants