|
| 1 | +From 566e1d61a500267c7849ad0b2552feec9c9a29a6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ernestas Kulik <ekulik@redhat.com> |
| 3 | +Date: Tue, 29 Jan 2019 09:50:46 +0100 |
| 4 | +Subject: [PATCH] gdbus: Avoid printing null strings |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +This mostly affects the 2.56 branch, but, given that GCC 9 is being |
| 10 | +stricter about passing null string pointers to printf-like functions, it |
| 11 | +might make sense to proactively fix such calls. |
| 12 | + |
| 13 | +gdbusauth.c: In function '_g_dbus_auth_run_server': |
| 14 | +gdbusauth.c:1302:11: error: '%s' directive argument is null |
| 15 | +[-Werror=format-overflow=] |
| 16 | + 1302 | debug_print ("SERVER: WaitingForBegin, read '%s'", |
| 17 | + line); |
| 18 | + | |
| 19 | + |
| 20 | +gdbusmessage.c: In function ‘g_dbus_message_to_blob’: |
| 21 | +gdbusmessage.c:2730:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=] |
| 22 | + 2730 | tupled_signature_str = g_strdup_printf ("(%s)", signature_str); |
| 23 | + | |
| 24 | +--- |
| 25 | + gio/gdbusauth.c | 2 +- |
| 26 | + gio/gdbusmessage.c | 5 ++--- |
| 27 | + 2 files changed, 3 insertions(+), 4 deletions(-) |
| 28 | + |
| 29 | +diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c |
| 30 | +index 1f8ea8057..752ec23fc 100644 |
| 31 | +--- a/gio/gdbusauth.c |
| 32 | ++++ b/gio/gdbusauth.c |
| 33 | +@@ -1272,9 +1272,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth, |
| 34 | + &line_length, |
| 35 | + cancellable, |
| 36 | + error); |
| 37 | +- debug_print ("SERVER: WaitingForBegin, read '%s'", line); |
| 38 | + if (line == NULL) |
| 39 | + goto out; |
| 40 | ++ debug_print ("SERVER: WaitingForBegin, read '%s'", line); |
| 41 | + if (g_strcmp0 (line, "BEGIN") == 0) |
| 42 | + { |
| 43 | + /* YAY, done! */ |
| 44 | +diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c |
| 45 | +index 3221b925d..3a1a1f9e9 100644 |
| 46 | +--- a/gio/gdbusmessage.c |
| 47 | ++++ b/gio/gdbusmessage.c |
| 48 | +@@ -2731,7 +2731,6 @@ g_dbus_message_to_blob (GDBusMessage *message, |
| 49 | + if (message->body != NULL) |
| 50 | + { |
| 51 | + gchar *tupled_signature_str; |
| 52 | +- tupled_signature_str = g_strdup_printf ("(%s)", signature_str); |
| 53 | + if (signature == NULL) |
| 54 | + { |
| 55 | + g_set_error (error, |
| 56 | +@@ -2739,10 +2738,10 @@ g_dbus_message_to_blob (GDBusMessage *message, |
| 57 | + G_IO_ERROR_INVALID_ARGUMENT, |
| 58 | + _("Message body has signature “%s” but there is no signature header"), |
| 59 | + signature_str); |
| 60 | +- g_free (tupled_signature_str); |
| 61 | + goto out; |
| 62 | + } |
| 63 | +- else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0) |
| 64 | ++ tupled_signature_str = g_strdup_printf ("(%s)", signature_str); |
| 65 | ++ if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0) |
| 66 | + { |
| 67 | + g_set_error (error, |
| 68 | + G_IO_ERROR, |
| 69 | +-- |
| 70 | +2.22.0 |
0 commit comments