cpw.darkrain42.xmpp.bosh: 2781d539: BOSH: Fix an off-by-one g_memdup that wa...
paul at darkrain42.org
paul at darkrain42.org
Mon Jan 19 13:31:24 EST 2009
-----------------------------------------------------------------
Revision: 2781d5390ae2e275324b76bf13b9dfb015691030
Ancestor: c7b6ee60d0ab51ee95763fb433469fe49d6f94dc
Author: paul at darkrain42.org
Date: 2009-01-19T18:25:38
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/2781d5390ae2e275324b76bf13b9dfb015691030
Modified files:
libpurple/protocols/jabber/bosh.c
ChangeLog:
BOSH: Fix an off-by-one g_memdup that was missing the null terminator.
Also, change some printf()s to purple_debug_* and a g_return_if_fail.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c fcc10aac72e5b4e1423f10d425c81fd73980ca66
+++ libpurple/protocols/jabber/bosh.c bf433e12fc36c42faa87ceb0a4125e049e632856
@@ -402,9 +402,11 @@ static void jabber_bosh_connection_http_
conn->receive_cb(conn, node);
xmlnode_free(node);
} else {
- printf("\njabber_bosh_connection_http_received_cb: XML ERROR: %s\n", res->data);
+ purple_debug_warning("jabber", "BOSH: Received invalid XML\n");
}
- } else purple_debug_info("jabber", "missing receive_cb of PurpleBOSHConnection.\n");
+ } else {
+ g_return_if_reached();
+ }
}
void jabber_bosh_connection_send(PurpleBOSHConnection *conn, xmlnode *node) {
@@ -531,12 +533,12 @@ jabber_bosh_http_connection_process(Purp
#warning For a pure HTTP 1.1 stack, this would need to be handled elsewhere.
if (bosh_conn->ready && g_queue_is_empty(conn->requests)) {
jabber_bosh_connection_send(bosh_conn, NULL);
- printf("\n SEND AN EMPTY REQUEST \n");
+ purple_debug_misc("jabber", "BOSH: Sending an empty request\n");
}
if (cb) {
conn->current_response->data_len = conn->body_len;
- conn->current_response->data = g_memdup(conn->buf->str + conn->handled_len, conn->body_len);
+ conn->current_response->data = g_memdup(conn->buf->str + conn->handled_len, conn->body_len + 1);
cb(conn->current_response, conn->userdata);
} else {
@@ -650,7 +652,7 @@ jabber_bosh_http_connection_send_request
packet = g_string_append(packet, req->data);
- printf("Sending %s\n", packet->str);
+ purple_debug_misc("jabber", "BOSH out: %s\n", packet->str);
/* TODO: Better error handling, circbuffer or possible integration with
* low-level code in jabber.c */
ret = write(conn->fd, packet->str, packet->len);
More information about the Commits
mailing list