Skip to content

Bound the decoder, firmware and user-data path copies - #919

Open
nullifyr wants to merge 1 commit into
DreamSourceLab:masterfrom
LANScapes:up/path-bounds
Open

nullifyr wants to merge 1 commit into
DreamSourceLab:masterfrom
LANScapes:up/path-bounds

Conversation

@nullifyr

@nullifyr nullifyr commented Oct 1, 2026

Copy link
Copy Markdown

Three fixed-size path copies can overflow:

  • AppControl::Init copied the decoder script directory into a 256-byte stack buffer with strcpy, which overflows when the application sits in a deeply nested folder. The path is now passed to srd_init as UTF-8 directly.
  • ds_set_firmware_resource_dir and ds_set_user_data_dir strcpy into 500-byte global buffers. A path that does not fit is now refused and logged.
  • The demo driver copied the user-data path into 500-byte stack buffers and appended /demo/<mode>/<pattern>.demo, which overflowed for any user-data path near the limit; pattern names longer than 49 bytes also overflowed a fixed short_name buffer. These strings are now built on the heap.

Checked with AddressSanitizer: before the change, a 499-byte user-data path overflowed dir_path_buf in get_pattern_mode_from_file; after it, the same path builds the full 517-byte demo path without error.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1

AppControl::Init copied the decoder script directory into a 256-byte
stack buffer with strcpy, which overflows when the application sits in
a deeply nested folder. Pass the UTF-8 bytes straight to srd_init.

ds_set_firmware_resource_dir and ds_set_user_data_dir strcpy into fixed
global buffers. Refuse a path that does not fit and log it, instead of
overflowing.

The demo driver copied the user-data path into 500-byte stack buffers
and appended "/demo/<mode>/<pattern>.demo", which overflowed for any
user-data path close to the limit; pattern names longer than 49 bytes
overflowed a fixed short_name buffer. Build these strings on the heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1
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