Loading lib/pingpong.c +9 −6 Original line number Original line Diff line number Diff line Loading @@ -286,7 +286,8 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, /* number of bytes in the current line, so far */ /* number of bytes in the current line, so far */ perline = (ssize_t)(ptr-pp->linestart_resp); perline = (ssize_t)(ptr-pp->linestart_resp); while((pp->nread_resp<BUFSIZE) && (keepon && !result)) { while((pp->nread_resp < (size_t)data->set.buffer_size) && (keepon && !result)) { if(pp->cache) { if(pp->cache) { /* we had data in the "cache", copy that instead of doing an actual /* we had data in the "cache", copy that instead of doing an actual Loading @@ -296,7 +297,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, * it would have been populated with something of size int to begin * it would have been populated with something of size int to begin * with, even though its datatype may be larger than an int. * with, even though its datatype may be larger than an int. */ */ DEBUGASSERT((ptr+pp->cache_size) <= (buf+BUFSIZE+1)); DEBUGASSERT((ptr+pp->cache_size) <= (buf+data->set.buffer_size+1)); memcpy(ptr, pp->cache, pp->cache_size); memcpy(ptr, pp->cache, pp->cache_size); gotbytes = (ssize_t)pp->cache_size; gotbytes = (ssize_t)pp->cache_size; free(pp->cache); /* free the cache */ free(pp->cache); /* free the cache */ Loading @@ -308,8 +309,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, enum protection_level prot = conn->data_prot; enum protection_level prot = conn->data_prot; conn->data_prot = PROT_CLEAR; conn->data_prot = PROT_CLEAR; #endif #endif DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1)); DEBUGASSERT((ptr + data->set.buffer_size - pp->nread_resp) <= result = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp, (buf + data->set.buffer_size + 1)); result = Curl_read(conn, sockfd, ptr, data->set.buffer_size - pp->nread_resp, &gotbytes); &gotbytes); #ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); Loading Loading @@ -402,7 +405,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, } } else if(keepon) { else if(keepon) { if((perline == gotbytes) && (gotbytes > BUFSIZE/2)) { if((perline == gotbytes) && (gotbytes > data->set.buffer_size/2)) { /* We got an excessive line without newlines and we need to deal /* We got an excessive line without newlines and we need to deal with it. We keep the first bytes of the line then we throw with it. We keep the first bytes of the line then we throw away the rest. */ away the rest. */ Loading @@ -414,7 +417,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, interested in the first piece */ interested in the first piece */ clipamount = 40; clipamount = 40; } } else if(pp->nread_resp > BUFSIZE/2) { else if(pp->nread_resp > (size_t)data->set.buffer_size/2) { /* We got a large chunk of data and there's potentially still /* We got a large chunk of data and there's potentially still trailing data to take care of, so we put any such part in the trailing data to take care of, so we put any such part in the "cache", clear the buffer to make space and restart. */ "cache", clear the buffer to make space and restart. */ Loading Loading
lib/pingpong.c +9 −6 Original line number Original line Diff line number Diff line Loading @@ -286,7 +286,8 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, /* number of bytes in the current line, so far */ /* number of bytes in the current line, so far */ perline = (ssize_t)(ptr-pp->linestart_resp); perline = (ssize_t)(ptr-pp->linestart_resp); while((pp->nread_resp<BUFSIZE) && (keepon && !result)) { while((pp->nread_resp < (size_t)data->set.buffer_size) && (keepon && !result)) { if(pp->cache) { if(pp->cache) { /* we had data in the "cache", copy that instead of doing an actual /* we had data in the "cache", copy that instead of doing an actual Loading @@ -296,7 +297,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, * it would have been populated with something of size int to begin * it would have been populated with something of size int to begin * with, even though its datatype may be larger than an int. * with, even though its datatype may be larger than an int. */ */ DEBUGASSERT((ptr+pp->cache_size) <= (buf+BUFSIZE+1)); DEBUGASSERT((ptr+pp->cache_size) <= (buf+data->set.buffer_size+1)); memcpy(ptr, pp->cache, pp->cache_size); memcpy(ptr, pp->cache, pp->cache_size); gotbytes = (ssize_t)pp->cache_size; gotbytes = (ssize_t)pp->cache_size; free(pp->cache); /* free the cache */ free(pp->cache); /* free the cache */ Loading @@ -308,8 +309,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, enum protection_level prot = conn->data_prot; enum protection_level prot = conn->data_prot; conn->data_prot = PROT_CLEAR; conn->data_prot = PROT_CLEAR; #endif #endif DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1)); DEBUGASSERT((ptr + data->set.buffer_size - pp->nread_resp) <= result = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp, (buf + data->set.buffer_size + 1)); result = Curl_read(conn, sockfd, ptr, data->set.buffer_size - pp->nread_resp, &gotbytes); &gotbytes); #ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); Loading Loading @@ -402,7 +405,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, } } else if(keepon) { else if(keepon) { if((perline == gotbytes) && (gotbytes > BUFSIZE/2)) { if((perline == gotbytes) && (gotbytes > data->set.buffer_size/2)) { /* We got an excessive line without newlines and we need to deal /* We got an excessive line without newlines and we need to deal with it. We keep the first bytes of the line then we throw with it. We keep the first bytes of the line then we throw away the rest. */ away the rest. */ Loading @@ -414,7 +417,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, interested in the first piece */ interested in the first piece */ clipamount = 40; clipamount = 40; } } else if(pp->nread_resp > BUFSIZE/2) { else if(pp->nread_resp > (size_t)data->set.buffer_size/2) { /* We got a large chunk of data and there's potentially still /* We got a large chunk of data and there's potentially still trailing data to take care of, so we put any such part in the trailing data to take care of, so we put any such part in the "cache", clear the buffer to make space and restart. */ "cache", clear the buffer to make space and restart. */ Loading