The relay driver built every sysfs path in fixed 80/96-byte stack buffers with unchecked snprintf. A WARDEN_GPIO_ROOT longer than about 70 bytes was cut short, so both relays silently read as unavailable. Production (/sys/class/gpio) is unaffected; the simulator and host-test seam are.
Change
relay_paths() formats all four paths of an operation (gpioN, export, gpioN/direction, gpioN/value) up front into PATH_MAX buffers and checks every snprintf return.
A root whose longest path does not fit is refused with a stderr line (relays: WARDEN_GPIO_ROOT is too long ...); available/get return false and set is a no-op. Nothing is truncated.
The export argument comes from a constant table, so no other runtime formatting remains.
Bound documented in relays.h; coverage counts updated in drivers/README.md and docs.
New cases: a 200-byte root through the fake io (the full untruncated path reaches the backend), a root exactly at the PATH_MAX bound (accepted), one byte over (refused and logged on available, get and set, io never touched), a root over PATH_MAX, and a real scratch tree under a root over 200 bytes (both relays available and switchable).
With relays.c reverted to flare-edge-next, the same harness reports 17 failures.
Fixes #10.
The relay driver built every sysfs path in fixed 80/96-byte stack buffers with unchecked `snprintf`. A `WARDEN_GPIO_ROOT` longer than about 70 bytes was cut short, so both relays silently read as unavailable. Production (`/sys/class/gpio`) is unaffected; the simulator and host-test seam are.
## Change
- `relay_paths()` formats all four paths of an operation (`gpioN`, `export`, `gpioN/direction`, `gpioN/value`) up front into PATH_MAX buffers and checks every `snprintf` return.
- A root whose longest path does not fit is refused with a stderr line (`relays: WARDEN_GPIO_ROOT is too long ...`); `available`/`get` return false and `set` is a no-op. Nothing is truncated.
- The export argument comes from a constant table, so no other runtime formatting remains.
- Bound documented in `relays.h`; coverage counts updated in `drivers/README.md` and docs.
## Tests
`make -C drivers/relays/test check`: 58 checks, 0 failures, 100% MC/DC (50/50 conditions, 65/65 lines).
New cases: a 200-byte root through the fake io (the full untruncated path reaches the backend), a root exactly at the PATH_MAX bound (accepted), one byte over (refused and logged on available, get and set, io never touched), a root over PATH_MAX, and a real scratch tree under a root over 200 bytes (both relays available and switchable).
With `relays.c` reverted to `flare-edge-next`, the same harness reports 17 failures.
Consumed by flare-edge via the submodule bump in blueflare/flare-edge#318.
Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
Sysfs paths were built in fixed 80/96-byte stack buffers with unchecked
snprintf, so a root longer than about 70 bytes was truncated and both relays
silently read as unavailable.
Each operation now formats all of its paths up front into PATH_MAX buffers
and checks every snprintf return. A root whose longest path does not fit is
refused with a stderr line and the call reports unavailable, off or no-op;
nothing is ever truncated. The export argument comes from a constant table
instead of runtime formatting.
Regression tests: a 200-byte root through the fake io (full path reaches
the backend), the exact PATH_MAX boundary, one byte over (refused and logged
on available, get and set, io untouched), and a real scratch tree under a
root over 200 bytes. MC/DC stays at 100% (50/50 conditions).
Fixes#10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
noah
merged commit 45569611da into flare-edge-next2026-10-02 12:14:30 -06:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #10.
The relay driver built every sysfs path in fixed 80/96-byte stack buffers with unchecked
snprintf. AWARDEN_GPIO_ROOTlonger than about 70 bytes was cut short, so both relays silently read as unavailable. Production (/sys/class/gpio) is unaffected; the simulator and host-test seam are.Change
relay_paths()formats all four paths of an operation (gpioN,export,gpioN/direction,gpioN/value) up front into PATH_MAX buffers and checks everysnprintfreturn.relays: WARDEN_GPIO_ROOT is too long ...);available/getreturn false andsetis a no-op. Nothing is truncated.relays.h; coverage counts updated indrivers/README.mdand docs.Tests
make -C drivers/relays/test check: 58 checks, 0 failures, 100% MC/DC (50/50 conditions, 65/65 lines).New cases: a 200-byte root through the fake io (the full untruncated path reaches the backend), a root exactly at the PATH_MAX bound (accepted), one byte over (refused and logged on available, get and set, io never touched), a root over PATH_MAX, and a real scratch tree under a root over 200 bytes (both relays available and switchable).
With
relays.creverted toflare-edge-next, the same harness reports 17 failures.Consumed by flare-edge via the submodule bump in blueflare/flare-edge#318.
Generated with Claude Code
https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg