Skip to content

Commit

Permalink
scheduler/ipp.c: Allocate device_uri via cupsdSetString()
Browse files Browse the repository at this point in the history
If a driverless printer has .local in its URI, we resolve the
URI and save the resolved one as new device URI. The problem was that
a local pointer was assigned to the structure which is passed to the
function as parameter, so the pointer became invalid once the execution
left the create_local_bg_thread() function.

We need to allocate the device URI via cupsdSetString() - the string is
then freed when the printer is deleted or cupsd shuts down.

Fixes OpenPrinting#419.
  • Loading branch information
zdohnal committed Jun 22, 2022
1 parent 7b4e1c8 commit 020609a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes in CUPS v2.4.3 (TBA)

- Added a title with device uri for found network printers (Issues #402, #393)
- Fixed configuration on RISC-V machines (Issue #404)
- Fixed the `device_uri` invalid pointer for driverless printers with `.local` hostname (Issue #419)
- Fixed an OpenSSL crash bug (Issue #409)
- Use localhost when printing via printer application (Issue #353)

Expand Down
2 changes: 1 addition & 1 deletion scheduler/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5307,7 +5307,7 @@ create_local_bg_thread(
return (NULL);
}

printer->device_uri = uri;
cupsdSetString(&printer->device_uri, 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)
Expand Down

0 comments on commit 020609a

Please sign in to comment.