Fix string size specifier in debug prints

Fri, 04 Nov 2022 02:32:53 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 04 Nov 2022 02:32:53 -0500
changeset 41883
c67c45d70006
parent 41882
e0a90a0a5bb2
child 41884
36684da1e60d

Fix string size specifier in debug prints

The `%*s` specifies the *width* of the string, but this was intended to specify
the maximum number of characters (in case the `GBytes` was unterminated), which is `%.*s`.

Testing Done:
Compiled only, though I did write a small test program with `printf` to confirm that this worked the intended way.

Reviewed at https://reviews.imfreedom.org/r/2023/

libpurple/protocols/gg/avatar.c file | annotate | diff | comparison | revisions
libpurple/protocols/gg/pubdir-prpl.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/bosh.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/gg/avatar.c	Fri Nov 04 00:47:21 2022 -0500
+++ b/libpurple/protocols/gg/avatar.c	Fri Nov 04 02:32:53 2022 -0500
@@ -274,7 +274,7 @@
 	}
 
 	buffer = g_bytes_get_data(response_body, &size);
-	purple_debug_info("gg", "ggp_avatar_own_sent: %*s", (int)size, buffer);
+	purple_debug_info("gg", "ggp_avatar_own_sent: %.*s", (int)size, buffer);
 	g_bytes_unref(response_body);
 }
 
--- a/libpurple/protocols/gg/pubdir-prpl.c	Fri Nov 04 00:47:21 2022 -0500
+++ b/libpurple/protocols/gg/pubdir-prpl.c	Fri Nov 04 02:32:53 2022 -0500
@@ -165,7 +165,7 @@
 	xml_raw = g_bytes_unref_to_data(response_body, &xml_size);
 
 	if (purple_debug_is_verbose() && purple_debug_is_unsafe()) {
-		purple_debug_misc("gg", "ggp_pubdir_got_data: xml=[%*s]",
+		purple_debug_misc("gg", "ggp_pubdir_got_data: xml=[%.*s]",
 		                  (int)xml_size, xml_raw);
 	}
 
@@ -806,7 +806,7 @@
 	}
 
 	buffer = g_bytes_get_data(response_body, &size);
-	purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%*s]",
+	purple_debug_info("gg", "ggp_pubdir_set_info_got_response: [%.*s]",
 	                  (int)size, buffer);
 	/* <result><status>0</status></result> */
 
--- a/libpurple/protocols/jabber/bosh.c	Fri Nov 04 00:47:21 2022 -0500
+++ b/libpurple/protocols/jabber/bosh.c	Fri Nov 04 02:32:53 2022 -0500
@@ -246,7 +246,7 @@
 		gsize length = 0;
 
 		body = g_bytes_get_data(response_body, &length);
-		purple_debug_misc("jabber-bosh", "received: %*s", (int)length, body);
+		purple_debug_misc("jabber-bosh", "received: %.*s", (int)length, body);
 	}
 
 	node = jabber_bosh_connection_parse(bosh_conn, msg, response_body, error);
@@ -430,7 +430,7 @@
 		gsize length = 0;
 
 		body = g_bytes_get_data(response_body, &length);
-		purple_debug_misc("jabber-bosh", "received (session creation): %*s",
+		purple_debug_misc("jabber-bosh", "received (session creation): %.*s",
 		                  (int)length, body);
 	}
 

mercurial