libpurple/protocols/mxit/http.c

branch
release-2.x.y
changeset 33744
879db2a9a59c
parent 30310
da2adcf3b4a0
child 33760
66611fba7197
child 33815
094a4b10e8d5
equal deleted inserted replaced
33743:a8aef1d340f2 33744:879db2a9a59c
114 /* copy partial headers if we have any part saved */ 114 /* copy partial headers if we have any part saved */
115 memcpy( buf, session->rx_dbuf, session->rx_i ); 115 memcpy( buf, session->rx_dbuf, session->rx_i );
116 buflen = session->rx_i; 116 buflen = session->rx_i;
117 117
118 /* read bytes from the socket */ 118 /* read bytes from the socket */
119 len = read( session->fd, buf + buflen, sizeof( buf ) - buflen ); 119 len = read( session->fd, buf + buflen, sizeof( buf ) - ( buflen + 1 ) );
120 if ( len <= 0 ) { 120 if ( len <= 0 ) {
121 /* connection has been terminated, or error occurred */ 121 /* connection has been terminated, or error occurred */
122 goto done; 122 goto done;
123 } 123 }
124 buf[buflen+len] = '\0';
124 125
125 //nextpacket: 126 //nextpacket:
126 127
127 #ifdef DEBUG_HTTP 128 #ifdef DEBUG_HTTP
128 purple_debug_info( MXIT_PLUGIN_ID, "HTTP POST READ 1: (%i)\n", len ); 129 purple_debug_info( MXIT_PLUGIN_ID, "HTTP POST READ 1: (%i)\n", len );
179 tmp = g_strndup( ch, tmp - ch ); 180 tmp = g_strndup( ch, tmp - ch );
180 bodylen = atoi( tmp ); 181 bodylen = atoi( tmp );
181 g_free( tmp ); 182 g_free( tmp );
182 tmp = NULL; 183 tmp = NULL;
183 184
184 if ( buflen > ( ( body - buf ) + bodylen ) ) { 185 if ( buflen + bodylen >= CP_MAX_PACKET ) {
186 /* this packet is way to big */
187 goto done;
188 }
189 else if ( buflen > ( ( body - buf ) + bodylen ) ) {
185 /* we have a second packet here */ 190 /* we have a second packet here */
186 next = body + bodylen; 191 next = body + bodylen;
187 session->rx_res = 0; 192 session->rx_res = 0;
188 } 193 }
189 else { 194 else {

mercurial