Skip to content

Fix buffer overflows, resource leaks, and unchecked I/O returns#52

Open
forrie wants to merge 1 commit into
philpem:masterfrom
forrie:master
Open

Fix buffer overflows, resource leaks, and unchecked I/O returns#52
forrie wants to merge 1 commit into
philpem:masterfrom
forrie:master

Conversation

@forrie

@forrie forrie commented Mar 9, 2026

Copy link
Copy Markdown

Summary

  • Replace strcpy/sprintf with snprintf in fbconfig.c to prevent buffer overflows when $HOME path is long
  • Fix file handle and malloc leaks in state.c ROM loading by restructuring error paths with goto cleanup
  • Add NULL check for ROM buffer malloc in state.c
  • Validate fread/fwrite return values in diskraw.c, diskimd.c, wd2010.c, and wd279x.c to detect and report short reads/writes
  • Log PTY write failures in i8274.c instead of silently discarding the return value
  • Rename lightbar.c to lightbar_data.h to reflect its role as embedded GIMP pixel data (not a compiled translation unit)

Test plan

  • make clean && make builds cleanly with zero new warnings (only pre-existing unused-function warnings in i8274.c on non-Linux)
  • Boot 3B1 UNIX from hard disk image to verify no regressions
  • Test floppy load/unload cycle
  • Test serial PTY connection (Linux)

🤖 Generated with Claude Code

- Replace strcpy/sprintf with snprintf in fbconfig.c to prevent
  buffer overflows when HOME path is long
- Fix file handle and malloc leaks in state.c ROM loading by
  restructuring error paths with goto cleanup
- Add NULL check for ROM buffer malloc in state.c
- Validate fread/fwrite return values in diskraw.c, diskimd.c,
  wd2010.c, and wd279x.c to detect short reads/writes
- Log PTY write failures in i8274.c instead of silently discarding
- Rename lightbar.c to lightbar_data.h to reflect its role as
  embedded GIMP pixel data (not a compiled translation unit)

Co-Authored-By: Claude Opus 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