Skip to content

Add the missing NULL terminators to the path lists - #57

Merged
wberube merged 1 commit into
OpenIPC:masterfrom
wjames111:fix/path-list-terminators
Oct 7, 2026
Merged

wberube merged 1 commit into
OpenIPC:masterfrom
wjames111:fix/path-list-terminators

Conversation

@wjames111

Copy link
Copy Markdown
Contributor

The device and config path arrays in watchdog.c, gpio.c and
app_config.c are walked with while (*path) but have no NULL element, so
any walk that does not find a match reads past the end of the array.
watchdog_start() and gpio_init() do this when neither device node
exists, app_config_open() when no config file is found, and
app_config_restore() on every call, since its loop has no break and then
builds the .bak name from the out-of-bounds pointer.

Built for infinity6e (SSC338Q). We've been running this fix on SSC338Q units.

The device and config path arrays in watchdog.c, gpio.c and
app_config.c are walked with while (*path) but have no NULL element, so
any walk that does not find a match reads past the end of the array.
watchdog_start() and gpio_init() do this when neither device node
exists, app_config_open() when no config file is found, and
app_config_restore() on every call, since its loop has no break and then
builds the .bak name from the out-of-bounds pointer.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Terminate configuration and device path lists with NULL

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Add NULL terminators so path searches stop safely when no file or device exists.
• Prevent configuration restore from reading past its path list on every complete traversal.
Diagram

graph TD
C["Path consumers"] --> P["NULL terminated lists"] --> T{"Path available?"}
T -->|Yes| A["Process candidate"] --> T
T -->|No| E["Exit loop safely"]
Loading
High-Level Assessment

Keep the NULL terminators: they directly satisfy the existing sentinel-based loops without changing their search behavior. Converting each loop to a length-based iteration would be more invasive for the same fix.

Files changed (3) +3 / -3

Bug fix (3) +3 / -3
app_config.cTerminate configuration path candidates +1/-1

Terminate configuration path candidates

• Adds a NULL element to the shared configuration path list. This bounds searches when no config file exists and lets restore finish iterating backup candidates safely.

src/app_config.c

gpio.cTerminate GPIO device path candidates +1/-1

Terminate GPIO device path candidates

• Adds a NULL element so gpio_init stops searching safely when neither GPIO path exists.

src/gpio.c

watchdog.cTerminate watchdog device path candidates +1/-1

Terminate watchdog device path candidates

• Adds a NULL element so watchdog_start can exhaust its device candidates without reading beyond the array.

src/watchdog.c

@wberube
wberube merged commit a776d7a into OpenIPC:master Oct 7, 2026
@wberube

wberube commented Oct 7, 2026

Copy link
Copy Markdown
Member

Once again, thank you very much for everything, can't wait to collaborate again!

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.

2 participants