Skip to content

xfer: guard against path buffer overflow in file command#31

Open
Swissola wants to merge 3 commits into
anthropics:mainfrom
Swissola:fix/path-buffer-overflow
Open

xfer: guard against path buffer overflow in file command#31
Swissola wants to merge 3 commits into
anthropics:mainfrom
Swissola:fix/path-buffer-overflow

Conversation

@Swissola
Copy link
Copy Markdown

Summary

  • Check the return value of snprintf when building the install path in the file command handler
  • Reject with a false ack if the combined path would overflow the 80-byte buffer

Motivation

/characters/<name>/<path> was written into char full[80] without validating the length of path from the bridge. snprintf silently truncates on overflow, so a long path would open a mangled filename with no error signalled back to the sender. In the worst case this creates a file at an unintended location on LittleFS.

The buffer is 80 bytes; /characters/ is 13, _xCharName up to 23, / is 1, leaving 42 bytes for the path component. Any bridge-supplied path longer than that now gets a {"ack":"file","ok":false} response rather than silent truncation.

Behaviour after this change

  • Paths that fit in 80 bytes: unchanged
  • Paths that would overflow: file ack returns ok: false, transfer is rejected cleanly
  • No change to the normal character install flow

Test plan

  • Normal character install with short filenames — unaffected
  • Bridge sends a file command with a path > 42 characters — device replies ok: false

🤖 Generated with Claude Code

Swissola and others added 3 commits May 22, 2026 17:37
sleep=Donald Duck, idle=Bongo Cat, busy=SpongeBob multitasking,
attention=Surprised Pikachu (Nouns glasses), celebrate=Peanuts party,
dizzy=Powerpuff Girls spiral eyes, heart=heart eyes ghost.

Source GIFs in characters/memes-src/, device-ready pack in characters/memes/.
Built with prep_character.py at 96x98px, 64 colours per frame.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track the current peer BD address in onConnect (extended overload).
bleRemoveCurrentBond() removes only that peer's LTK from NVS. The
"unpair" JSON command now calls this instead of bleClearBonds(), so
each host unpairs itself independently. bleClearBonds() is reserved
for factory reset only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The file path was constructed with snprintf into an 80-byte buffer without
checking whether the combined /characters/<name>/<path> string exceeded it.
A long path from the bridge would silently truncate, opening a mangled
filename. Check the snprintf return value and reject with a false ack if the
result would overflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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