Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. WalkthroughThe change defines ChangesEscaped SSID buffer sizing
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ColinMcInnes
left a comment
There was a problem hiding this comment.
I agree, no security hole here, just a truncated log, and this should resolve that.
rsmarples
left a comment
There was a problem hiding this comment.
This looks like a good improvement, but what do you think of my suggestion?
| { | ||
| struct if_options *ifo; | ||
| char pssid[PROFILE_LEN]; | ||
| char pssid[(IF_SSIDLEN * 4) + 1]; |
There was a problem hiding this comment.
Why not do this in dhcpcd.h
#define IF_SSIDSTRLEN ((IF_SSIDLEN * 4) + 1)
#define PROFILE_LEN IF_SSIDSTRLEN
Then you could re-use IF_SSIDSTRLEN in dhcpcd_reportssid
There was a problem hiding this comment.
Unless I'm missing something PROFILE_LEN doesn't need to be the same size as an expanded SSID? Though clearly IF_SSIDSTRLEN is a better answer and I found what looked like three more place where it would be used (PR updated).
There was a problem hiding this comment.
We could break it out to make a specific PSSID len. But either way it should be defined in dhcpcd.h instead of magic math'd in the function.
9ae8b19 to
678e6e4
Compare
rsmarples
left a comment
There was a problem hiding this comment.
This now looks good, just fix the formatting please.
You can run make format with clang-format v21 installed to fix.
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. Add IF_SSIDSTRLEN for this and use it everywhere an escaped SSID is stored. dhcpcd_selectprofile() used PROFILE_LEN, which is 64 causing: dhcpcd_selectprofile: No buffer space available in the log, the resulting call to read_config() then gets an empty SSID, so no `ssid ...` block matches. dhcpcd_reportssid() and make_env() used IF_SSIDLEN * 4, which is 128 and correct except for the NUL, so they fail only on a 32-byte SSID whose every byte escapes. The former then logs an error instead of the "connected to Access Point" line and the latter omits ifssid from the hook environment. dhcp_set_leasefile() and the lease file name buffers were already sized correctly, so switching them is only for consistency. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
678e6e4 to
528e982
Compare
|
Thanks! |
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