From 5de2a4b5f3072edd99e7ec3fae59e7aa2e44e090 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Dec 08 2020 10:13:03 +0000 Subject: import spice-gtk-0.38-5.el8 --- diff --git a/SOURCES/0017-empty_cd_clicked_cb-g_free-basename.patch b/SOURCES/0017-empty_cd_clicked_cb-g_free-basename.patch new file mode 100644 index 0000000..18f855b --- /dev/null +++ b/SOURCES/0017-empty_cd_clicked_cb-g_free-basename.patch @@ -0,0 +1,33 @@ +From 20eebc549da508c82e139120b577b047c76964c3 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Wed, 11 Nov 2020 14:12:19 +0200 +Subject: [PATCH 17/22] empty_cd_clicked_cb: g_free basename + +Fix the following static analyzer warning: + src/usb-device-widget.c:224: leaked_storage: Failing to save or free + storage allocated by "g_path_get_basename(filename)" leaks it. + +Signed-off-by: Uri Lublin +--- + src/usb-device-widget.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c +index 257e9e1..0ff4e52 100644 +--- a/src/usb-device-widget.c ++++ b/src/usb-device-widget.c +@@ -220,8 +220,10 @@ empty_cd_clicked_cb(GtkToggleButton *toggle, gpointer user_data) + + rc = spice_usb_device_manager_create_shared_cd_device(priv->manager, filename, &err); + if (!rc && err != NULL) { ++ const gchar *basename = g_path_get_basename(filename); + gchar *err_msg = g_strdup_printf(_("shared CD %s, %s"), +- g_path_get_basename(filename), err->message); ++ basename, err->message); ++ g_free((gpointer)basename); + + SPICE_DEBUG("Failed to create %s", err_msg); + spice_usb_device_widget_add_err_msg(self, err_msg); +-- +2.28.0 + diff --git a/SOURCES/0018-spice_usbutil_parse_usbids-verify-at-least-one-vendo.patch b/SOURCES/0018-spice_usbutil_parse_usbids-verify-at-least-one-vendo.patch new file mode 100644 index 0000000..299cd8c --- /dev/null +++ b/SOURCES/0018-spice_usbutil_parse_usbids-verify-at-least-one-vendo.patch @@ -0,0 +1,44 @@ +From 032ca202f839fe1c49cddfd2b0459f9fecc23c86 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Wed, 11 Nov 2020 20:03:57 +0200 +Subject: [PATCH 18/22] spice_usbutil_parse_usbids: verify at least one vendor + and product + +Fixes the following clang warning: + src/usbutil.c:148:52: warning: Use of zero-allocated memory + ... + + product_info[product_count].product_id = id; + ^ + 146| while (isspace(line[0])) + 147| line++; + 148|-> product_info[product_count].product_id = id; + 149| snprintf(product_info[product_count].name, + 150| PRODUCT_NAME_LEN, "%s", line); + +Signed-off-by: Uri Lublin +--- + src/usbutil.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/usbutil.c b/src/usbutil.c +index 7d7f38a..f29302b 100644 +--- a/src/usbutil.c ++++ b/src/usbutil.c +@@ -113,6 +113,13 @@ static gboolean spice_usbutil_parse_usbids(gchar *path) + usbids_vendor_count++; + } + ++ if (usbids_vendor_info == 0 || product_count == 0) { ++ usbids_vendor_count = -1; ++ g_strfreev(lines); ++ g_free(contents); ++ return FALSE; ++ } ++ + usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count); + product_info = g_new(usb_product_info, product_count); + +-- +2.28.0 + diff --git a/SOURCES/0019-sink_event_probe-do-not-keep-duration-in-a-variable.patch b/SOURCES/0019-sink_event_probe-do-not-keep-duration-in-a-variable.patch new file mode 100644 index 0000000..f27f04a --- /dev/null +++ b/SOURCES/0019-sink_event_probe-do-not-keep-duration-in-a-variable.patch @@ -0,0 +1,42 @@ +From bb4999f6e450aa1b1270ade7113966869fc4ed27 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Wed, 11 Nov 2020 20:34:09 +0200 +Subject: [PATCH 19/22] sink_event_probe: do not keep duration in a variable + +If not ENABLE_RECORDER, then duration is assigned a value +but is never used - as the compiler optimizes it out. + +Fixes the following clang warning: + src/channel-display-gst.c:443:21: warning: Value stored to + 'duration' during its initialization is never read + +Signed-off-by: Uri Lublin +--- + src/channel-display-gst.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c +index c58a90f..36db3a3 100644 +--- a/src/channel-display-gst.c ++++ b/src/channel-display-gst.c +@@ -439,7 +439,6 @@ sink_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer data) + if (l) { + SpiceGstFrame *gstframe = l->data; + const SpiceFrame *frame = gstframe->encoded_frame; +- int64_t duration = g_get_monotonic_time() - frame->creation_time; + /* Note that queue_len (the length of the queue prior to adding + * this frame) is crucial to correctly interpret the decoding time: + * - Less than MAX_DECODED_FRAMES means nothing blocked the +@@ -450,7 +449,8 @@ sink_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer data) + record(frames_stats, + "frame mm_time %u size %u creation time %" PRId64 + " decoded time %" PRId64 " queue %u before %u", +- frame->mm_time, frame->size, frame->creation_time, duration, ++ frame->mm_time, frame->size, frame->creation_time, ++ g_get_monotonic_time() - frame->creation_time, + decoder->decoding_queue->length, gstframe->queue_len); + + if (!decoder->appsink) { +-- +2.28.0 + diff --git a/SOURCES/0020-mark_false_event_id-is-guint-assign-0-to-it-not-FALS.patch b/SOURCES/0020-mark_false_event_id-is-guint-assign-0-to-it-not-FALS.patch new file mode 100644 index 0000000..7984e75 --- /dev/null +++ b/SOURCES/0020-mark_false_event_id-is-guint-assign-0-to-it-not-FALS.patch @@ -0,0 +1,26 @@ +From df47365c32711bae5dfa163f8eba7b0f741326d6 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Thu, 19 Nov 2020 19:30:54 +0200 +Subject: [PATCH 20/22] mark_false_event_id is guint, assign 0 to it not FALSE + +Signed-off-by: Uri Lublin +--- + src/channel-display.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/channel-display.c b/src/channel-display.c +index 023baa1..f52ef12 100644 +--- a/src/channel-display.c ++++ b/src/channel-display.c +@@ -1971,7 +1971,7 @@ static void display_handle_surface_create(SpiceChannel *channel, SpiceMsgIn *in) + create_canvas(channel, surface); + if (c->mark_false_event_id != 0) { + g_source_remove(c->mark_false_event_id); +- c->mark_false_event_id = FALSE; ++ c->mark_false_event_id = 0; + } + } else { + surface->primary = false; +-- +2.28.0 + diff --git a/SOURCES/0021-usb-backend-create_emulated_device-assert-address-32.patch b/SOURCES/0021-usb-backend-create_emulated_device-assert-address-32.patch new file mode 100644 index 0000000..f4df551 --- /dev/null +++ b/SOURCES/0021-usb-backend-create_emulated_device-assert-address-32.patch @@ -0,0 +1,33 @@ +From 35f6926328cd415f6ba24efe49c3f990e44a8948 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Sun, 22 Nov 2020 16:21:00 +0200 +Subject: [PATCH 21/22] usb-backend: create_emulated_device: assert address < + 32 + +This may fix the following static analyzer issue: + src/usb-backend.c:1507: large_shift: In expression "1 << address", left + shifting by more than 31 bits has undefined behavior. + The shift amount, "address", is 32. + +Signed-off-by: Uri Lublin +--- + src/usb-backend.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/usb-backend.c b/src/usb-backend.c +index 857488e..c76d576 100644 +--- a/src/usb-backend.c ++++ b/src/usb-backend.c +@@ -1482,6 +1482,9 @@ spice_usb_backend_create_emulated_device(SpiceUsbBackend *be, + } + } + ++ // for static analyzers: it is already checked above ++ g_assert(address < 32); ++ + dev = g_new0(SpiceUsbDevice, 1); + dev->device_info.bus = BUS_NUMBER_FOR_EMULATED_USB; + dev->device_info.address = address; +-- +2.28.0 + diff --git a/SOURCES/0022-spice-utils-allocate-ctx-after-g_return_val_if_fail.patch b/SOURCES/0022-spice-utils-allocate-ctx-after-g_return_val_if_fail.patch new file mode 100644 index 0000000..ae8543f --- /dev/null +++ b/SOURCES/0022-spice-utils-allocate-ctx-after-g_return_val_if_fail.patch @@ -0,0 +1,48 @@ +From 1068e4d0e39f3d8f3390102863a02eaed7ee81b1 Mon Sep 17 00:00:00 2001 +From: Uri Lublin +Date: Mon, 23 Nov 2020 15:38:43 +0200 +Subject: [PATCH 22/22] spice-utils: allocate ctx after g_return_val_if_fail + +Fix the following issue: + Error: RESOURCE_LEAK + src/spice-util.c:235: alloc_fn: Storage is returned + from allocation function "whc_new". + src/spice-util.c:235: var_assign: Assigning: "ctx" = + storage returned from "whc_new(instance_obj, gobject)". + src/spice-util.c:237: leaked_storage: Variable "ctx" + going out of scope leaks the storage it points to. + + 235| WeakHandlerCtx *ctx = whc_new (instance_obj, gobject); + 236| + 237|-> g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); + 238| g_return_val_if_fail (detailed_signal != NULL, 0); + 239| g_return_val_if_fail (c_handler != NULL, 0); + +Signed-off-by: Uri Lublin +--- + src/spice-util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/spice-util.c b/src/spice-util.c +index 1e49982..d0c56ba 100644 +--- a/src/spice-util.c ++++ b/src/spice-util.c +@@ -231,7 +231,6 @@ gulong spice_g_signal_connect_object (gpointer instance, + GConnectFlags connect_flags) + { + GObject *instance_obj = G_OBJECT (instance); +- WeakHandlerCtx *ctx = whc_new (instance_obj, gobject); + + g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); + g_return_val_if_fail (detailed_signal != NULL, 0); +@@ -240,6 +239,7 @@ gulong spice_g_signal_connect_object (gpointer instance, + g_return_val_if_fail ( + (connect_flags & ~(G_CONNECT_AFTER|G_CONNECT_SWAPPED)) == 0, 0); + ++ WeakHandlerCtx *ctx = whc_new (instance_obj, gobject); + if (connect_flags & G_CONNECT_SWAPPED) + ctx->closure = g_cclosure_new_object_swap (c_handler, gobject); + else +-- +2.28.0 + diff --git a/SPECS/spice-gtk.spec b/SPECS/spice-gtk.spec index 99eded0..81d8bdf 100644 --- a/SPECS/spice-gtk.spec +++ b/SPECS/spice-gtk.spec @@ -2,7 +2,7 @@ Name: spice-gtk Version: 0.38 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A GTK+ widget for SPICE clients Group: System Environment/Libraries @@ -29,6 +29,13 @@ Patch0014: 0014-Remove-some-warnings-from-Clang-static-analyzer.patch Patch0015: 0015-ssl_verify-Do-not-check-IP-if-we-fail-to-resolve-it.patch Patch0016: 0016-usb-backend-Fix-spice-usbredir-redirect-on-connect-o.patch +Patch0017: 0017-empty_cd_clicked_cb-g_free-basename.patch +Patch0018: 0018-spice_usbutil_parse_usbids-verify-at-least-one-vendo.patch +Patch0019: 0019-sink_event_probe-do-not-keep-duration-in-a-variable.patch +Patch0020: 0020-mark_false_event_id-is-guint-assign-0-to-it-not-FALS.patch +Patch0021: 0021-usb-backend-create_emulated_device-assert-address-32.patch +Patch0022: 0022-spice-utils-allocate-ctx-after-g_return_val_if_fail.patch + BuildRequires: meson BuildRequires: git-core BuildRequires: gnupg2 @@ -196,6 +203,10 @@ gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0} %{_bindir}/spicy-stats %changelog +* Thu Dec 03 2020 Uri Lublin - 0.38-5 +- Fix more static analyzer issues + Resolves: rhbz#1839104 + * Mon Nov 9 18:01:40 IST 2020 Uri Lublin - 0.38-4 - Fix some static analyzer issues Resolves: rhbz#1839104