From 411f7a38d3f4d63005094fb8ee7555fcb315b240 Mon Sep 17 00:00:00 2001 From: Armaan Sandhu Date: Sun, 1 Nov 2026 19:35:40 -0500 Subject: [PATCH] cups-browsed: fix BrowseAllow /0, link-local check and overwritten queue result "BrowseAllow 0.0.0.0/0" shifted a 32-bit value by 32, wich is undefined and gave a mask of 255.255.255.255 on x86 instead of 0.0.0.0, so it matched almost nothing. the link-local address check tested for 'B' twice and never for 'b', so lowercase feb* addresses didn't get their interface added. queue_overwritten() set its result to 2 when the PPD changed even if it had just found a changed device URI. the queue was then re-created instead of being released, undoing the users change. only use 2 if the device URI is unchanged, as the caller expects. --- daemon/cups-browsed.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/daemon/cups-browsed.c b/daemon/cups-browsed.c index bb6c2de2..7ac2b31d 100644 --- a/daemon/cups-browsed.c +++ b/daemon/cups-browsed.c @@ -6328,7 +6328,8 @@ queue_overwritten (remote_printer_t *p) p->queue_name, (p->nickname ? p->nickname : "(no PPD)"), (makemodel ? makemodel : "(NickName not readable)")); - overwritten = 2; + if (overwritten == 0) + overwritten = 2; } } } @@ -10151,7 +10152,7 @@ resolve_callback(void* arg) if (!strncasecmp(addrstr + 4, "fe", 2) && (addrstr[6] == '8' || addrstr[6] == '9' || addrstr[6] == 'A' || addrstr[6] == 'B' || - addrstr[6] == 'a' || addrstr[6] == 'B')) + addrstr[6] == 'a' || addrstr[6] == 'b')) // Link-local address, needs specification of interface snprintf(addrstr + addrlen + 4, 256 - addrlen - 4, "%%%s]", @@ -11411,8 +11412,9 @@ read_browseallow_value (const char *value, allow_sense_t sense) if (bits > 32) goto fail; - allow->mask.ipv4.sin_addr.s_addr = htonl (((0xffffffff << (32 - bits)) & - 0xffffffff)); + // Shifting a 32-bit value by 32 is undefined + allow->mask.ipv4.sin_addr.s_addr = + (bits ? htonl (0xffffffffU << (32 - bits)) : 0); } } else if (inet_aton (value, &addr))