Repository navigation
driverless: escape TXT record values in the device and driver lists - #809
Merged
tillkamppeter merged 1 commit intoNov 20, 2026
Merged
Conversation
listPrintersInArray() builds make, make-and-model and the device ID from the DNS-SD TXT record (usb_MFG, usb_MDL, product, ty) of every IPP printer ippfind finds, and prints them verbatim inside the quoted fields of the backend discovery line and of the "driverless list" line. Any host on the local network can advertise those values. A '"' in one of them closes the field, so whatever follows lands in device-info, device-id and device-location when cups-deviced parses the discovery line, or in ppd-device-id, ppd-product, ppd-psversion and ppd-type when cups-driverd parses the driver list. A trailing '\' makes cups-deviced read the closing quote as escaped and drop the printer. Report the discovered device with cupsBackendReport(), which escapes '\' and '"' the way cups-deviced unescapes them, as the parallel backend already does. cups-driverd has no escape syntax for its quoted fields, so drop '"' from the strings in list mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
listPrintersInArray()takes make, model and the 1284 device ID from the DNS-SD TXT record (usb_MFG,usb_MDL,product,ty) of every IPP printerippfindturns up and prints them unescaped inside the quoted fields of the backend discovery line (network <uri> "make-and-model" "info" "device-id" "") and of thedriverless listline that cups-driverd reads. Anything on the local network can advertise those values. A"in one of them closes the field. In discovery mode the rest of the value ends up in cups-deviced's device-info, device-id and device-location. In list mode it fills cups-driverd's ppd-device-id, ppd-product, ppd-psversion and ppd-type, and the "driverless, cups-filters" text gets pushed into ppd-type. A trailing\makes cups-deviced treat the closing quote as escaped, so it rejects the line and the printer disappears from the list.Discovery mode now goes through
cupsBackendReport(), which escapes\and"the way cups-deviced unescapes them. backend/parallel.c already reports its devices that way. cups-driverd parses its list withsscanf("\"%127[^\"]\"...")and has no escape syntax, so list mode drops"from the three strings.To check it, I compiled
listPrintersInArray()from this file against small stubs and fed it ippfind records whoseusb_MDLholdsLaserJet 400" "MFG:Evil;MDL:Injected;" "Lobbyor ends in a backslash. I parsed the output with copies of the CUPS 2.4get_device()(cups-deviced) andload_drivers()(cups-driverd) field parsers. Before the patch the injected text came back as separate device-id / location / ppd-type fields and the backslash entry was dropped. With the patch every value stays inside its own field, and output for an ordinary printer is byte-identical. I don't have libcups/libcupsfilters/libppd on this machine, so the full build and the cppcheck job are left to CI.