/pidgin/main: 8b37d3593783: bonjour: Similify code and get rid o...

Daniel Atallah datallah at pidgin.im
Sun Feb 24 11:37:32 EST 2013


Changeset: 8b37d35937839f958cdabace15665b12ad65c70c
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2013-02-24 11:37 -0500
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/8b37d3593783

Description:

bonjour: Similify code and get rid of some unnecessary control character removal

 * If the other side sends an invalid character, the xml parsing will fail (as it should)

diffstat:

 libpurple/protocols/bonjour/jabber.c |  23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diffs (49 lines):

diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -411,16 +411,18 @@ static void
 _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition)
 {
 	BonjourJabberConversation *bconv = data;
-	gint len, message_length;
+	gssize len;
 	static char message[4096];
 
 	/* Read the data from the socket */
-	if ((len = recv(socket, message, sizeof(message) - 1, 0)) == -1) {
+	if ((len = recv(socket, message, sizeof(message) - 1, 0)) < 0) {
 		/* There have been an error reading from the socket */
-		if (errno != EAGAIN) {
+		if (len != -1 || errno != EAGAIN) {
 			const char *err = g_strerror(errno);
 
-			purple_debug_warning("bonjour", "receive error: %s\n", err ? err : "(null)");
+			purple_debug_warning("bonjour",
+					"receive of %" G_GSSIZE_FORMAT " error: %s\n",
+					len, err ? err : "(null)");
 
 			bonjour_jabber_close_conversation(bconv);
 			if (bconv->pb != NULL) {
@@ -439,19 +441,12 @@ static void
 		purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (name) ? name : "(unknown)");
 		bonjour_jabber_stream_ended(bconv);
 		return;
-	} else {
-		message_length = len;
-		message[message_length] = '\0';
-
-		while (message_length > 0 && g_ascii_iscntrl(message[message_length - 1])) {
-			message[message_length - 1] = '\0';
-			message_length--;
-		}
 	}
 
-	purple_debug_info("bonjour", "Receive: -%s- %d bytes\n", message, len);
+	message[len] = '\0';
 
-	bonjour_parser_process(bconv, message, message_length);
+	purple_debug_info("bonjour", "Receive: -%s- %" G_GSSIZE_FORMAT " bytes\n", message, len);
+	bonjour_parser_process(bconv, message, len);
 }
 
 struct _stream_start_data {



More information about the Commits mailing list