diff -r a8aef1d340f2 -r 879db2a9a59c libpurple/protocols/mxit/http.c --- a/libpurple/protocols/mxit/http.c Mon Feb 11 01:03:34 2013 -0800 +++ b/libpurple/protocols/mxit/http.c Mon Feb 11 01:09:30 2013 -0800 @@ -116,11 +116,12 @@ buflen = session->rx_i; /* read bytes from the socket */ - len = read( session->fd, buf + buflen, sizeof( buf ) - buflen ); + len = read( session->fd, buf + buflen, sizeof( buf ) - ( buflen + 1 ) ); if ( len <= 0 ) { /* connection has been terminated, or error occurred */ goto done; } + buf[buflen+len] = '\0'; //nextpacket: @@ -181,7 +182,11 @@ g_free( tmp ); tmp = NULL; - if ( buflen > ( ( body - buf ) + bodylen ) ) { + if ( buflen + bodylen >= CP_MAX_PACKET ) { + /* this packet is way to big */ + goto done; + } + else if ( buflen > ( ( body - buf ) + bodylen ) ) { /* we have a second packet here */ next = body + bodylen; session->rx_res = 0;