cURL / Mailing Lists / curl-library / Single Mail

curl-library

problem with chunked content type "Problem (2) in the Chunked-Encoded data"

From: Gabriel Grebenar \(1&1\) <gabriel.grebenar_at_onlinehome.de>
Date: Tue, 10 Mar 2015 09:08:46 +0100

Hello,

In version 7.35 my program failed in chunk parser function
Curl_httpchunk_read() with error message " Problem (2) in the
Chunked-Encoded data".

I've examined the source code and found the reason. It's because errno was
set to ERANGE by a previous function call but never cleared. So errno was
set to ERANGE
before function curlx_strtoofft() was called and that's why
CHUNKE_ILLEGAL_HEX was returned by function Curl_httpchunk_read() regardless
of the result of function curlx_strtoofft().

This problem was fixed in version 7.36 by statement "if((ch->datasize ==
CURL_OFF_T_MAX) && (errno == ERANGE))" , but what about datasize value
CURL_OFF_T_MIN which was not checked?

I would propose a code change in http_chunked.c in function
Curl_httpchunk_read() as follows:
        ...
        errno = 0; /* thread safe */
        ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16);
        if(errno == ERANGE)
                /* overflow is an error */
                return CHUNKE_ILLEGAL_HEX;
        ch->state = CHUNK_LF; /* now wait for the CRLF */

Regards,
        Gabriel

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-03-10