Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
libcups does not initialize defaults in some cases #5642
I am using CUPS 2.2.12 on Ubuntu Eoan.
It demonstrates that the internal global data structure cg of libcups in some cases gets used but not initialized.
it should display the IPP attributes of the CUPS queue, but in reality it tells that the queue does not exist. When looking into error_log (in debug mode) one sees that a get-printer-attributes IPP request is done, but to "file:/dev/null" (the device URI in the destination record) and not to the printer URI.
What happens here is that the first two "if" conditions resolve to false and the third to true, setting dflags to CUPS_DEST_FLAGS_DEVICE and so the device URI being used for the following get-printer-attributes IPP request and that fails.
If cg->server is "/run/cups/cups.sock" or "localhost" as expected and cg->ipp_port is 631 as expected, this would resolve to false and the last "else" would set dflags to CUPS_DEST_FLAGS_NONE and so the get-printer-attributes IPP request is applied to the CUPS queue.
it calls the function ippPort() in the very beginning before it calls any other function of libcups. The ippPort() function calls the internal function _cupsSetDefaults() of libcups which populates the cg data structure with the defaults.
The sample program:
… libcups The CUPS backend runs into a bug of libcups, of the default server name, port, domain socket file name not being initialized depending on which functions of the library are used. See this upstream bug report on CUPS: apple/cups#5642 A simple call of "ippPort()" in the very beginning of the backend executable solves the problem. This also caused the issue #2 which is solved now, too.
The original program (cpdb-backend-cups, version 1.1.0) uses cupsEnumDests() as shown in