Relay driver truncates long WARDEN_GPIO_ROOT paths #10

Closed
opened 2026-10-02 09:29:26 -06:00 by noah · 1 comment
Owner

drivers/relays/relays.c builds every sysfs path into fixed stack buffers (p[80] in exported(), ex[80] and p[96] in ensure_ready(), p[96] in warden_relay_get() / warden_relay_set()) with snprintf and never checks for truncation. With WARDEN_GPIO_ROOT set to a root longer than about 70 characters the paths are cut short, every exists() / read fails, and both relays silently report unavailable ("The relay GPIO could not be claimed").

Found while rendering the Relays page in the simulator for flare-edge#312 with a fake GPIO tree under a long scratch path; a short root works. Production uses /sys/class/gpio, so panels are not affected: this bites the simulator and host-test seam only.

Expected: a root that does not fit is reported (log and false) instead of producing a truncated path, or the buffers are sized from PATH_MAX. Regression test: the existing fake-io coverage with a long root.

Not fixed in the flare-edge#312 round: the fix belongs on a branch of this SDK repo plus a submodule bump in flare-edge, outside that UI-only change.

`drivers/relays/relays.c` builds every sysfs path into fixed stack buffers (`p[80]` in `exported()`, `ex[80]` and `p[96]` in `ensure_ready()`, `p[96]` in `warden_relay_get()` / `warden_relay_set()`) with `snprintf` and never checks for truncation. With `WARDEN_GPIO_ROOT` set to a root longer than about 70 characters the paths are cut short, every `exists()` / `read` fails, and both relays silently report unavailable ("The relay GPIO could not be claimed"). Found while rendering the Relays page in the simulator for flare-edge#312 with a fake GPIO tree under a long scratch path; a short root works. Production uses `/sys/class/gpio`, so panels are not affected: this bites the simulator and host-test seam only. Expected: a root that does not fit is reported (log and `false`) instead of producing a truncated path, or the buffers are sized from `PATH_MAX`. Regression test: the existing fake-io coverage with a long root. Not fixed in the flare-edge#312 round: the fix belongs on a branch of this SDK repo plus a submodule bump in flare-edge, outside that UI-only change.
noah closed this issue 2026-10-02 12:14:30 -06:00
Author
Owner

Fixed by b18ed38, merged into flare-edge-next in #11; flare-edge picks it up in blueflare/flare-edge#318.

Fixed by b18ed38, merged into flare-edge-next in #11; flare-edge picks it up in blueflare/flare-edge#318.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blueflare/bfe-core1106-sdk#10