--- a/libpurple/protocols/mxit/http.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/http.c Fri Jun 03 12:57:02 2016 -0500
@@ -63,9 +63,9 @@
* @param pktlen The length of the packet data
* @return Return -1 on error, otherwise 0
-static int mxit_http_raw_write( int fd, const char* pktdata, int pktlen )
+static int mxit_http_raw_write( int fd, const char* pktdata, size_t pktlen )
@@ -315,22 +315,25 @@
* @param session The MXit session object
* @param host The server name to connect to
* @param port The port number to connect to
- * @param data The HTTP request data (including HTTP headers etc.)
+ * @param header The HTTP header. + * @param data The HTTP request data. * @param datalen The HTTP request data length
-void mxit_http_send_request( struct MXitSession* session, char* host, int port, const char* data, int datalen )
+void mxit_http_send_request( struct MXitSession* session, char* host, int port, gchar* header, const char* data, size_t datalen ) PurpleProxyConnectData* con = NULL;
struct http_request* req;
+ size_t headerlen = strlen( header ); /* build the http request */
req = g_new0( struct http_request, 1 );
- req->data = g_malloc0( datalen );
- memcpy( req->data, data, datalen );
- req->datalen = datalen;
+ req->data = g_malloc0( headerlen + datalen ); + memcpy( req->data, header, headerlen ); + memcpy( req->data + headerlen, data, datalen ); + req->datalen = headerlen + datalen; /* open connection to the HTTP server */
con = purple_proxy_connect( NULL, session->acc, host, port, mxit_cb_http_connect, req );
--- a/libpurple/protocols/mxit/http.h Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/http.h Fri Jun 03 12:57:02 2016 -0500
@@ -35,11 +35,11 @@
-void mxit_http_send_request( struct MXitSession* session, char* host, int port, const char* data, int datalen );
+void mxit_http_send_request( struct MXitSession* session, char* host, int port, gchar* header, const char* data, size_t datalen ); --- a/libpurple/protocols/mxit/protocol.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/protocol.c Fri Jun 03 12:57:02 2016 -0500
@@ -334,11 +334,10 @@
static void mxit_write_http_post( struct MXitSession* session, struct tx_packet* packet )
- char request[256 + packet->datalen];
/* extract the HTTP host name and host port number to connect to */
ok = purple_url_parse( session->http_server, &host_name, &host_port, NULL, NULL, NULL );
@@ -350,8 +349,8 @@
packet->header[packet->headerlen - 1] = '\0';
- /* build the HTTP request packet */
- reqlen = g_snprintf( request, 256,
+ /* build the HTTP request header */ + httpheader = g_strdup_printf( "POST %s?%s HTTP/1.1\r\n"
"User-Agent: " MXIT_HTTP_USERAGENT "\r\n"
"Content-Type: application/octet-stream\r\n"
@@ -364,17 +363,17 @@
packet->datalen - MXIT_MS_OFFSET
- /* copy over the packet body data (could be binary) */
- memcpy( request + reqlen, packet->data + MXIT_MS_OFFSET, packet->datalen - MXIT_MS_OFFSET );
- reqlen += packet->datalen;
purple_debug_info( MXIT_PLUGIN_ID, "HTTP POST:\n" );
- dump_bytes( session, request, reqlen );
+ dump_bytes( session, httpheader, strlen( httpheader ) ); + dump_bytes( session, packet->data + MXIT_MS_OFFSET, packet->datalen - MXIT_MS_OFFSET ); /* send the request to the HTTP server */
- mxit_http_send_request( session, host_name, host_port, request, reqlen );
+ mxit_http_send_request( session, host_name, host_port, httpheader, packet->data + MXIT_MS_OFFSET, packet->datalen - MXIT_MS_OFFSET );