Skip to content

dnssd.c: reject oversized TXT record sets in cupsDNSSDServiceAdd() on Windows - #228

Merged
michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/dnssd-win32-txt-array-overflow
Nov 22, 2026
Merged

michaelrsweet merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/dnssd-win32-txt-array-overflow

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

Summary

On the Windows (WinDNS) backend, cupsDNSSDServiceAdd() builds the key/value pointer arrays it passes to DnsServiceConstructInstance() into fixed 256-entry stack arrays (keys[256], values[256]), but never checks the caller-supplied num_txt against that limit before writing keys[j]/values[j] for every entry in the loop that fills them.

Fix

Reject the call up front if num_txt exceeds the array size, the same way this function already rejects other invalid states (report_error() + ret = false + goto done;).

Test plan

  • Windows build: cupsDNSSDServiceAdd() with num_txt <= 256 behaves unchanged.
  • Windows build: cupsDNSSDServiceAdd() called with num_txt > 256 now returns false and reports "Too many TXT record key/value pairs." instead of overflowing the stack arrays.

… Windows

The WinDNS backend builds the key/value pointer arrays passed to
DnsServiceConstructInstance() into fixed 256-entry stack arrays
(keys[256], values[256]), but never checked the caller-supplied
num_txt count against that limit before writing keys[j]/values[j]
for every entry. A caller registering a service with more than 256
TXT key/value pairs overflows both stack arrays. Reject the request
up front instead, matching this function's existing error-reporting
convention.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@michaelrsweet michaelrsweet self-assigned this Nov 22, 2026
@michaelrsweet michaelrsweet added bug Something isn't working platform issue Issue is specific to an OS or desktop labels Nov 22, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Nov 22, 2026
@michaelrsweet
michaelrsweet merged commit 7b0b32f into OpenPrinting:master Nov 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working platform issue Issue is specific to an OS or desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants