fix issues reported by Coverity scan

This commit is contained in:
Zdenek Dohnal 2021-10-11 10:18:07 +02:00
parent f7e480f800
commit 2a8b981113
2 changed files with 98 additions and 1 deletions

93
scp-covscan.patch Normal file
View File

@ -0,0 +1,93 @@
diff --git a/scp-dbus-service.py b/scp-dbus-service.py
index fcccf89..b623014 100644
--- a/scp-dbus-service.py
+++ b/scp-dbus-service.py
@@ -380,7 +380,7 @@ class ConfigPrintingNewPrinterDialog(dbus.service.Object):
def on_printer_modified(self, obj, name, ppd_has_changed):
debugprint ("%s: printer modified" % self)
g_killtimer.remove_hold ()
- self.PrinterModifed (name, ppd_has_changed)
+ self.PrinterModified (name, ppd_has_changed)
self.remove_handles ()
self.remove_from_connection ()
diff --git a/udev/udev-configure-printer.c b/udev/udev-configure-printer.c
index 5d7c25e..fd158b0 100644
--- a/udev/udev-configure-printer.c
+++ b/udev/udev-configure-printer.c
@@ -205,6 +205,12 @@ add_device_uri (struct device_uris *uris,
uris->n_uris = 1;
uris->uri[0] = uri_copy;
}
+ else
+ {
+ syslog (LOG_ERR, "out of memory");
+ free (uri_copy);
+ return;
+ }
}
else
{
@@ -847,6 +853,7 @@ device_id_from_devpath (struct udev *udev, const char *devpath,
udev_device_unref (dev);
free (devicefilepath);
+ g_free(device_id);
return usb_device_devpath;
}
@@ -1274,7 +1281,6 @@ find_matching_device_uris (struct device_id *id,
{
add_usb_uri_mapping (&map, devpath, uris);
write_usb_uri_map (map);
- free_usb_uri_map (map);
}
return uris->n_uris;
@@ -1527,6 +1533,11 @@ skip:
free(this_device_uri_n);
this_device_uri_n = NULL;
}
+ if (device_uri_n != NULL)
+ {
+ free(device_uri_n);
+ device_uri_n = NULL;
+ }
if (!attr)
break;
}
@@ -1625,6 +1636,7 @@ do_add (const char *cmd, const char *devaddr)
if (udev == NULL)
{
syslog (LOG_ERR, "udev_new failed");
+ free_usb_uri_map (map);
exit (1);
}
@@ -1643,7 +1655,7 @@ do_add (const char *cmd, const char *devaddr)
if (!id.mfg || !id.mdl)
{
clear_device_id (&id);
- free (map);
+ free_usb_uri_map (map);
free (usb_device_devpath);
return 1;
}
@@ -1668,7 +1680,7 @@ do_add (const char *cmd, const char *devaddr)
{
syslog (LOG_ERR, "no corresponding CUPS device found");
clear_device_id (&id);
- free (map);
+ free_usb_uri_map (map);
return 0;
}
@@ -1722,7 +1734,7 @@ do_add (const char *cmd, const char *devaddr)
clear_device_id (&id);
free_device_uris (&device_uris);
- free (map);
+ free_usb_uri_map (map);
return 0;
}

View File

@ -9,12 +9,13 @@
Summary: A printer administration tool
Name: system-config-printer
Version: 1.5.15
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv2+
URL: https://github.com/%{username}/%{name}
Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.xz
# all upstream patches, remove with new release
Patch01: scp-covscan.patch
# gcc is no longer in buildroot by default
@ -253,6 +254,9 @@ exit 0
%endif
%changelog
* Mon Sep 06 2021 Zdenek Dohnal <zdohnal@redhat.com> - 1.5.15-5
- fix issues reported by Coverity scan
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.15-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild