From 9ae8b19ea63e105c1d1c46887c74b75cedd33ed1 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Tue, 8 Sep 2026 09:40:46 +0100 Subject: [PATCH] dhcpcd: size the escaped-SSID buffers for the worst case 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 --- src/dhcpcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dhcpcd.c b/src/dhcpcd.c index bf277bbc..d052d1c1 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -628,7 +628,7 @@ int dhcpcd_selectprofile(struct interface *ifp, const char *profile) { struct if_options *ifo; - char pssid[PROFILE_LEN]; + char pssid[(IF_SSIDLEN * 4) + 1]; if (ifp->ssid_len) { ssize_t r; @@ -717,7 +717,7 @@ dhcpcd_initstate(struct interface *ifp, unsigned long long options) static void dhcpcd_reportssid(struct interface *ifp) { - char pssid[IF_SSIDLEN * 4]; + char pssid[(IF_SSIDLEN * 4) + 1]; if (print_string(pssid, sizeof(pssid), OT_ESCSTRING, ifp->ssid, ifp->ssid_len) == -1) {