This commit is contained in:
Zdenek Dohnal 2019-11-01 16:03:53 +01:00
parent b13b64c8bf
commit db189fd38d
2 changed files with 43 additions and 30 deletions

View File

@ -1,15 +1,5 @@
From cf9903466c1a2d18a701f3b5e8c7e03483e1244d Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Mon, 14 Oct 2019 16:39:28 +0200
Subject: [PATCH] udev-configure-printer: Add checks for NULL
---
NEWS | 1 +
udev/udev-configure-printer.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS diff --git a/NEWS b/NEWS
index f4b774e5..0b53aa8e 100644 index f4b774e..0b53aa8 100644
--- a/NEWS --- a/NEWS
+++ b/NEWS +++ b/NEWS
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
@ -20,10 +10,33 @@ index f4b774e5..0b53aa8e 100644
1.5.12 changes 1.5.12 changes
-------------- --------------
diff --git a/udev/udev-configure-printer.c b/udev/udev-configure-printer.c diff --git a/udev/udev-configure-printer.c b/udev/udev-configure-printer.c
index 83092fc2..d753bbea 100644 index 83092fc..8f6ce3d 100644
--- a/udev/udev-configure-printer.c --- a/udev/udev-configure-printer.c
+++ b/udev/udev-configure-printer.c +++ b/udev/udev-configure-printer.c
@@ -1411,7 +1411,7 @@ for_each_matching_queue (struct device_uris *device_uris, @@ -1285,7 +1285,8 @@ normalize_device_uri(const char *str_orig)
{
int i, j;
int havespace = 0;
- char *str;
+ char *str = NULL;
+ char *cropped_str = NULL;
if (str_orig == NULL)
return NULL;
@@ -1333,7 +1334,11 @@ normalize_device_uri(const char *str_orig)
(strstr(str, "packard ") == str) ||
(strstr(str, "apollo ") == str) ||
(strstr(str, "usb ") == str))
- str = strchr(str, ' ') + 1;
+ {
+ cropped_str = strdup(strchr(str, ' ') + 1);
+ free(str);
+ str = cropped_str;
+ }
return str;
}
@@ -1411,7 +1416,7 @@ for_each_matching_queue (struct device_uris *device_uris,
const char *printer_state_message = NULL; const char *printer_state_message = NULL;
int state = 0; int state = 0;
size_t i, l; size_t i, l;
@ -32,30 +45,27 @@ index 83092fc2..d753bbea 100644
const char *ps1, *ps2, *pi1, *pi2; const char *ps1, *ps2, *pi1, *pi2;
while (attr && ippGetGroupTag (attr) != IPP_TAG_PRINTER) while (attr && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
@@ -1448,6 +1448,8 @@ for_each_matching_queue (struct device_uris *device_uris, @@ -1507,13 +1512,21 @@ for_each_matching_queue (struct device_uris *device_uris,
for (i = 0; i < device_uris->n_uris; i++) break;
{ }
device_uri_n = normalize_device_uri(device_uris->uri[i]); }
+ if (this_device_uri_n == NULL || device_uri_n == NULL) + if (device_uri_n != NULL)
+ goto skip; + {
/* As for the same device different URIs can come out when the + free(device_uri_n);
device is accessed via the usblp kernel module or via low- + device_uri_n = NULL;
level USB (libusb) we cannot simply compare URIs, must + }
@@ -1512,8 +1514,12 @@ for_each_matching_queue (struct device_uris *device_uris, }
firstqueue = 0; firstqueue = 0;
skip: skip:
- free(device_uri_n); - free(device_uri_n);
- free(this_device_uri_n); - free(this_device_uri_n);
+ if (device_uri_n != NULL)
+ free(device_uri_n);
+ device_uri_n = NULL;
+ if (this_device_uri_n != NULL) + if (this_device_uri_n != NULL)
+ {
+ free(this_device_uri_n); + free(this_device_uri_n);
+ this_device_uri_n = NULL; + this_device_uri_n = NULL;
+ }
if (!attr) if (!attr)
break; break;
} }
--
2.21.0

View File

@ -9,7 +9,7 @@
Summary: A printer administration tool Summary: A printer administration tool
Name: system-config-printer Name: system-config-printer
Version: 1.5.12 Version: 1.5.12
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2+ License: GPLv2+
URL: https://github.com/%{username}/%{name} URL: https://github.com/%{username}/%{name}
Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.gz Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.gz
@ -213,6 +213,9 @@ touch %buildroot%{_localstatedir}/run/udev-configure-printer/usb-uris
exit 0 exit 0
%changelog %changelog
* Thu Oct 31 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.5.12-3
- whole fix for #1765915
* Tue Oct 29 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.5.12-2 * Tue Oct 29 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.5.12-2
- 1765915 - abrt in udev-configure-printer - 1765915 - abrt in udev-configure-printer