1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

lib: fix 0-length Curl_client_write calls

Closes #6954
This commit is contained in:
Jacob Hoffman-Andrews 2021-04-27 15:48:01 -07:00 committed by Daniel Stenberg
parent f4b85d24b2
commit 5c932f8fe9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 16 additions and 6 deletions

View File

@ -985,7 +985,8 @@ new_unencoding_writer(struct Curl_easy *data,
return writer;
}
/* Write data using an unencoding writer stack. */
/* Write data using an unencoding writer stack. "nbytes" is not
allowed to be 0. */
CURLcode Curl_unencode_write(struct Curl_easy *data,
struct contenc_writer *writer,
const char *buf, size_t nbytes)

View File

@ -1515,8 +1515,17 @@ CURLcode Curl_pop3_write(struct Curl_easy *data, char *str, size_t nread)
if(prev) {
/* If the partial match was the CRLF and dot then only write the CRLF
as the server would have inserted the dot */
result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)POP3_EOB,
strip_dot ? prev - 1 : prev);
if(strip_dot && prev - 1 > 0) {
result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)POP3_EOB,
prev - 1);
}
else if(!strip_dot) {
result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)POP3_EOB,
prev);
}
else {
result = CURLE_OK;
}
if(result)
return result;

View File

@ -604,7 +604,7 @@ static CURLcode chop_write(struct Curl_easy *data,
/* Curl_client_write() sends data to the write callback(s)
The bit pattern defines to what "streams" to write to. Body and/or header.
The defines are in sendf.h of course.
The defines are in sendf.h of course. "len" is not allowed to be 0.
If CURL_DO_LINEEND_CONV is enabled, data is converted IN PLACE to the
local character encoding. This is a problem and should be changed in

View File

@ -830,7 +830,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
Make sure that ALL_CONTENT_ENCODINGS contains all the
encodings handled here. */
if(data->set.http_ce_skip || !k->writer_stack) {
if(!k->ignorebody) {
if(!k->ignorebody && nread) {
#ifndef CURL_DISABLE_POP3
if(conn->handler->protocol & PROTO_FAMILY_POP3)
result = Curl_pop3_write(data, k->str, nread);
@ -840,7 +840,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
nread);
}
}
else if(!k->ignorebody)
else if(!k->ignorebody && nread)
result = Curl_unencode_write(data, k->writer_stack, k->str, nread);
}
k->badheader = HEADER_NORMAL; /* taken care of now */