Skip to content

dhcpcd: size the escaped-SSID buffers for the worst case - #727

Open
akiernan wants to merge 1 commit into
NetworkConfiguration:masterfrom
akiernan:dhcpcd-size-the-escaped-ssid-buffers
Open

dhcpcd: size the escaped-SSID buffers for the worst case#727
akiernan wants to merge 1 commit into
NetworkConfiguration:masterfrom
akiernan:dhcpcd-size-the-escaped-ssid-buffers

Conversation

@akiernan

@akiernan akiernan commented Sep 8, 2026

Copy link
Copy Markdown

print_string() renders each non-printable byte as \NNN - four characters plus terminating NUL, failing with ENOBUFS if there is no room for it. An SSID is up to IF_SSIDLEN (32) bytes, so an escaped SSID needs up to (IF_SSIDLEN * 4) + 1 = 129 bytes.

dhcpcd_selectprofile() uses PROFILE_LEN, which is 64 causing:

dhcpcd_selectprofile: No buffer space available

in the log, the resulting call to read_config() then gets an an empty SSID, so no profile ssid ... block matches.

dhcpcd_reportssid() uses IF_SSIDLEN * 4, which is 128 and correct except for the NUL, so it fails only on a 32-byte SSID whose every byte escapes. It then logs an error instead of the "connected to Access Point" line.

Closes #726

print_string() renders each non-printable byte as \NNN - four characters
plus terminating NUL, failing with ENOBUFS if there is no room for it.
An SSID is up to IF_SSIDLEN (32) bytes, so an escaped SSID needs up to
(IF_SSIDLEN * 4) + 1 = 129 bytes.

dhcpcd_selectprofile() uses PROFILE_LEN, which is 64 causing:

  dhcpcd_selectprofile: No buffer space available

in the log, the resulting call to read_config() then gets an an empty
SSID, so no `profile ssid ...` block matches.

dhcpcd_reportssid() uses IF_SSIDLEN * 4, which is 128 and correct except
for the NUL, so it fails only on a 32-byte SSID whose every byte escapes.
It then logs an error instead of the "connected to Access Point" line.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a024e1b5-5046-46b3-9722-cda48a36e20f

📥 Commits

Reviewing files that changed from the base of the PR and between 42ca579 and 9ae8b19.

📒 Files selected for processing (1)
  • src/dhcpcd.c

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

The change increases both escaped SSID buffers by one byte. This provides space for the terminating NUL byte in dhcpcd_selectprofile and dhcpcd_reportssid.

Changes

SSID buffer sizing

Layer / File(s) Summary
Expand SSID formatting buffers
src/dhcpcd.c
Both SSID formatting buffers now use (IF_SSIDLEN * 4) + 1 bytes.

Priority: ➖ Normal — Impact reflects medium issue severity.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 9ae8b

Escaped maximum-length SSIDs can now be matched and reported without running out of buffer space. The targeted sizing correction is ready to merge.

Suggested reviewers: rsmarples

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: sizing escaped-SSID buffers for the worst case.
Description check ✅ Passed The description directly explains the buffer-sizing defect, its impact, and the fix for both affected functions.
Linked Issues check ✅ Passed The changes satisfy issue #726 by allocating (IF_SSIDLEN * 4) + 1 bytes in both escaped-SSID buffers, preserving NUL termination and addressing profile matching and reporting failures.
Out of Scope Changes check ✅ Passed The two buffer-size changes are directly related to issue #726 and the stated objectives. No unrelated changes are present.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ColinMcInnes ColinMcInnes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, no security hole here, just a truncated log, and this should resolve that.

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.

dhcpcd_selectprofile: No buffer space available

2 participants