diff options
author | Patrick Monnerat <patrick@monnerat.net> | 2019-02-14 16:03:24 +0100 |
---|---|---|
committer | Patrick Monnerat <patrick@monnerat.net> | 2019-02-14 16:03:24 +0100 |
commit | 539d17b0de923b9a122f551fddac2a82ed95d9b2 (patch) | |
tree | b453dc9d85aefd1cebf3916cef262fad14a15d9c /lib/transfer.c | |
parent | a75de9de40b30231ca59d8058f11a73a08779dd3 (diff) | |
download | curl-539d17b0de923b9a122f551fddac2a82ed95d9b2.tar.gz |
transfer.c: do not compute length of undefined hex buffer.
On non-ascii platforms, the chunked hex header was measured for char code
conversion length, even for chunked trailers that do not have an hex header.
In addition, the efective length is already known: use it.
Since the hex length can be zero, only convert if needed.
Reported by valgrind.
Diffstat (limited to 'lib/transfer.c')
-rw-r--r-- | lib/transfer.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 27fe79074..32c855be2 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -296,10 +296,10 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, here, knowing they'll become CRLFs later on. */ - char hexbuffer[11]; + char hexbuffer[11] = ""; + int hexlen = 0; const char *endofline_native; const char *endofline_network; - int hexlen = 0; if( #ifdef CURL_DO_LINEEND_CONV @@ -354,12 +354,14 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, length = nread; else /* just translate the protocol portion */ - length = strlen(hexbuffer); - result = Curl_convert_to_network(data, data->req.upload_fromhere, - length); - /* Curl_convert_to_network calls failf if unsuccessful */ - if(result) - return result; + length = hexlen; + if(length) { + result = Curl_convert_to_network(data, data->req.upload_fromhere, + length); + /* Curl_convert_to_network calls failf if unsuccessful */ + if(result) + return result; + } } #endif /* CURL_DOES_CONVERSIONS */ |