0003-gdbus-Avoid-printing-null-strings.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From 79492bb914e419c54298ba6324e3d595e51c16c3 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. This mostly affects the 2.56 branch, but, given that GCC 9 is being
  9. stricter about passing null string pointers to printf-like functions, it
  10. might make sense to proactively fix such calls.
  11. gdbusauth.c: In function '_g_dbus_auth_run_server':
  12. gdbusauth.c:1302:11: error: '%s' directive argument is null
  13. [-Werror=format-overflow=]
  14. 1302 | debug_print ("SERVER: WaitingForBegin, read '%s'",
  15. line);
  16. |
  17. gdbusmessage.c: In function ‘g_dbus_message_to_blob’:
  18. gdbusmessage.c:2730:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  19. 2730 | tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
  20. |
  21. Signed-off-by: Grzegorz Blach <grzegorz@blach.pl>
  22. ---
  23. gio/gdbusauth.c | 2 +-
  24. gio/gdbusmessage.c | 5 ++---
  25. 2 files changed, 3 insertions(+), 4 deletions(-)
  26. diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
  27. index 1f8ea8057..752ec23fc 100644
  28. --- a/gio/gdbusauth.c
  29. +++ b/gio/gdbusauth.c
  30. @@ -1272,9 +1272,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
  31. &line_length,
  32. cancellable,
  33. error);
  34. - debug_print ("SERVER: WaitingForBegin, read '%s'", line);
  35. if (line == NULL)
  36. goto out;
  37. + debug_print ("SERVER: WaitingForBegin, read '%s'", line);
  38. if (g_strcmp0 (line, "BEGIN") == 0)
  39. {
  40. /* YAY, done! */
  41. diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
  42. index 3221b925d..3a1a1f9e9 100644
  43. --- a/gio/gdbusmessage.c
  44. +++ b/gio/gdbusmessage.c
  45. @@ -2731,7 +2731,6 @@ g_dbus_message_to_blob (GDBusMessage *message,
  46. if (message->body != NULL)
  47. {
  48. gchar *tupled_signature_str;
  49. - tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
  50. if (signature == NULL)
  51. {
  52. g_set_error (error,
  53. @@ -2739,10 +2738,10 @@ g_dbus_message_to_blob (GDBusMessage *message,
  54. G_IO_ERROR_INVALID_ARGUMENT,
  55. _("Message body has signature “%s” but there is no signature header"),
  56. signature_str);
  57. - g_free (tupled_signature_str);
  58. goto out;
  59. }
  60. - else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
  61. + tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
  62. + if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
  63. {
  64. g_set_error (error,
  65. G_IO_ERROR,
  66. --
  67. 2.21.0