From 5edeb99bda86a1d85bcad5e27501b01f7c68077c Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Fri, 29 May 2020 12:53:58 +0800 Subject: [PATCH] Avoid printing null strings to fix build failed this change has given better compatible with both gcc8 and gcc9 toolchain, should be maintained util upstream fixes This mostly affects the 2.56 branch, but, given that GCC 9 is being stricter about passing null string pointers to printf-like functions, it might make sense to proactively fix such calls. Signed-off-by: Chunmei Xu Signed-off-by: Liwei Ge Signed-off-by: weitao zhou --- 0001-gdbus-Avoid-printing-null-strings.patch | 71 ++++++++++++++++++++ glib2.spec | 9 ++- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 0001-gdbus-Avoid-printing-null-strings.patch diff --git a/0001-gdbus-Avoid-printing-null-strings.patch b/0001-gdbus-Avoid-printing-null-strings.patch new file mode 100644 index 0000000..8d7b19a --- /dev/null +++ b/0001-gdbus-Avoid-printing-null-strings.patch @@ -0,0 +1,71 @@ +From 566e1d61a500267c7849ad0b2552feec9c9a29a6 Mon Sep 17 00:00:00 2001 +From: Ernestas Kulik +Date: Tue, 29 Jan 2019 09:50:46 +0100 +Subject: [PATCH] gdbus: Avoid printing null strings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This mostly affects the 2.56 branch, but, given that GCC 9 is being +stricter about passing null string pointers to printf-like functions, it +might make sense to proactively fix such calls. + +gdbusauth.c: In function '_g_dbus_auth_run_server': +gdbusauth.c:1302:11: error: '%s' directive argument is null +[-Werror=format-overflow=] + 1302 | debug_print ("SERVER: WaitingForBegin, read '%s'", + line); + | + +gdbusmessage.c: In function ‘g_dbus_message_to_blob’: +gdbusmessage.c:2730:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=] + 2730 | tupled_signature_str = g_strdup_printf ("(%s)", signature_str); + | +--- + gio/gdbusauth.c | 2 +- + gio/gdbusmessage.c | 5 ++--- + 2 files changed, 3 insertions(+), 4 deletions(-) + +diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c +index 1f8ea80..752ec23 100644 +--- a/gio/gdbusauth.c ++++ b/gio/gdbusauth.c +@@ -1272,9 +1272,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth, + &line_length, + cancellable, + error); +- debug_print ("SERVER: WaitingForBegin, read '%s'", line); + if (line == NULL) + goto out; ++ debug_print ("SERVER: WaitingForBegin, read '%s'", line); + if (g_strcmp0 (line, "BEGIN") == 0) + { + /* YAY, done! */ +diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c +index 3221b92..3a1a1f9 100644 +--- a/gio/gdbusmessage.c ++++ b/gio/gdbusmessage.c +@@ -2731,7 +2731,6 @@ g_dbus_message_to_blob (GDBusMessage *message, + if (message->body != NULL) + { + gchar *tupled_signature_str; +- tupled_signature_str = g_strdup_printf ("(%s)", signature_str); + if (signature == NULL) + { + g_set_error (error, +@@ -2739,10 +2738,10 @@ g_dbus_message_to_blob (GDBusMessage *message, + G_IO_ERROR_INVALID_ARGUMENT, + _("Message body has signature “%s” but there is no signature header"), + signature_str); +- g_free (tupled_signature_str); + goto out; + } +- else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0) ++ tupled_signature_str = g_strdup_printf ("(%s)", signature_str); ++ if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0) + { + g_set_error (error, + G_IO_ERROR, +-- +1.8.3.1 + diff --git a/glib2.spec b/glib2.spec index 5ef1063..014f79c 100644 --- a/glib2.spec +++ b/glib2.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %global _changelog_trimtime %(date +%s -d "1 year ago") # See https://fedoraproject.org/wiki/Packaging:Python_Appendix#Manual_byte_compilation @@ -5,7 +6,7 @@ Name: glib2 Version: 2.56.4 -Release: 158%{?dist} +Release: 158%{anolis_release}%{?dist} Summary: A library of handy utility functions License: LGPLv2+ @@ -67,6 +68,9 @@ Patch7: 105.patch # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/532 Patch8: 532.patch +# Backported from git +Patch41: 0001-gdbus-Avoid-printing-null-strings.patch + # https://bugzilla.redhat.com/show_bug.cgi?id=1777213 # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1176 Patch9: 1176.patch @@ -307,6 +311,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %{_datadir}/installed-tests %changelog +* Thu Jan 20 2022 Weitao Zhou 2.56.4-158.0.1 +- gdbus: Avoid printing null strings to fix build failed with gcc9.2 + * Wed Dec 01 2021 Michael Catanzaro - 2.56.4-158 - Fix GNetworkMonitor after NetworkManager D-Bus API changes - Resolves: #2014652 -- Gitee