fix invalid pointer during resolving mDNS uri

This commit is contained in:
Zdenek Dohnal 2022-08-02 15:00:23 +02:00
parent 0b30e4cfe1
commit 2e3c51880e
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From 020609ad9eb84ab5a4c602ff604b2f208a6cdb8d Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Wed, 22 Jun 2022 09:23:45 +0200
Subject: [PATCH] scheduler/ipp.c: Allocate device_uri via cupsdSetString()
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 #419.
---
CHANGES.md | 1 +
scheduler/ipp.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 3a849bdb5..b722712f6 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -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)
--
2.37.1

View File

@ -15,7 +15,7 @@ Summary: CUPS printing system
Name: cups Name: cups
Epoch: 1 Epoch: 1
Version: 2.4.2 Version: 2.4.2
Release: 2%{?dist} Release: 3%{?dist}
License: ASL 2.0 License: ASL 2.0
Url: https://openprinting.github.io/cups/ Url: https://openprinting.github.io/cups/
# Apple stopped uploading the new versions into github, use OpenPrinting fork # Apple stopped uploading the new versions into github, use OpenPrinting fork
@ -67,6 +67,7 @@ Patch100: cups-lspp.patch
%endif %endif
#### UPSTREAM PATCHES (starts with 1000) #### #### UPSTREAM PATCHES (starts with 1000) ####
Patch1001: 0001-scheduler-ipp.c-Allocate-device_uri-via-cupsdSetStri.patch
##### Patches removed because IMHO they aren't no longer needed ##### Patches removed because IMHO they aren't no longer needed
##### but still I'll leave them in git in case their removal ##### but still I'll leave them in git in case their removal
@ -270,6 +271,7 @@ to CUPS daemon. This solution will substitute printer drivers and raw queues in
%patch13 -p1 -b .dymo-deviceid %patch13 -p1 -b .dymo-deviceid
# UPSTREAM PATCHES # UPSTREAM PATCHES
%patch1001 -p1 -b .invalid-pointer-uri
%if %{lspp} %if %{lspp}
@ -660,6 +662,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man7/ippeveps.7.gz %{_mandir}/man7/ippeveps.7.gz
%changelog %changelog
* Tue Aug 02 2022 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.2-3
- fix invalid pointer during resolving mDNS uri
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:2.4.2-2 * Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:2.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild