Skip to content

Commit

Permalink
scheduler/ipp.c: Resolve possible mDNS uri (Fixes #340, #343)
Browse files Browse the repository at this point in the history
Users sometimes pass URIs from dnssd and driverless backends as a
device URI for IPP Everywhere queues. These URIs have mDNS hostnames in
it, so they need to be resolved before used in connection.
  • Loading branch information
zdohnal committed Mar 2, 2022
1 parent 377e542 commit 777c1ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changes in CUPS v2.4.2 (TBA)
----------------------------

- Fixed conditional jump based on uninitialized value in cups/ppd.c (Issue #329)
- mDNS hostname in device uri is not resolved when installaling a permanent
IPP Everywhere queue (Issues #340, #343)


Changes in CUPS v2.4.1 (27th January 2020)
Expand Down
4 changes: 3 additions & 1 deletion scheduler/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "cupsd.h"
#include <cups/http-private.h>

This comment has been minimized.

Copy link
@michaelrsweet

michaelrsweet Mar 2, 2022

Member

I believe that cups-private.h already includes this header so it shouldn't be necessary...

This comment has been minimized.

Copy link
@zdohnal

zdohnal Mar 3, 2022

Author Member

@michaelrsweet ack, I'll check it and update it accordingly.

#include <cups/ppd-private.h>

#ifdef __APPLE__
Expand Down Expand Up @@ -5271,6 +5272,7 @@ create_local_bg_thread(
userpass[256], /* User:pass */
host[256], /* Hostname */
resource[1024], /* Resource path */
uri[1024], /* Resolved URI, unused */
line[1024]; /* Line from PPD */
int port; /* Port number */
http_encryption_t encryption; /* Type of encryption to use */
Expand All @@ -5292,7 +5294,7 @@ create_local_bg_thread(

cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Generating PPD file from \"%s\"...", printer->name, printer->device_uri);

if (httpSeparateURI(HTTP_URI_CODING_ALL, printer->device_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
if (httpSeparateURI(HTTP_URI_CODING_ALL, _httpResolveURI(printer->device_uri, uri, sizeof(uri), _HTTP_RESOLVE_DEFAULT, NULL, NULL), scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)

This comment has been minimized.

Copy link
@michaelrsweet

michaelrsweet Mar 2, 2022

Member

You should check for "._tcp." in the URI to determine whether resolving is necessary...

This comment has been minimized.

Copy link
@zdohnal

zdohnal Mar 3, 2022

Author Member

@michaelrsweet ok, though the same is done in _httpResolveURI(), but probably we can spare the function call and speed up the scheduler by it... ok, I'll update.

Thank you for the review! Normally I would have done a PR, but it seemed more people are getting hit by it, so I've pushed the fix which I'd verified.

This comment has been minimized.

Copy link
@michaelrsweet

michaelrsweet Mar 3, 2022

Member

No worries, the fixes were fine I just saw some minor optimizations. Thanks!

{
cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Bad device URI \"%s\".", printer->name, printer->device_uri);
return (NULL);
Expand Down

0 comments on commit 777c1ec

Please sign in to comment.