Skip to content

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

Open
ManasBagul23 wants to merge 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/dnssd-win32-txt-array-overflow
Open

ManasBagul23 wants to merge 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.

This branch has not been deployed

No deployments
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.

1 participant