cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: problem with curl 7.35 using MinGW

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 12 Feb 2014 13:58:12 +0100 (CET)

On Wed, 12 Feb 2014, LM wrote:

> Checking the runtime library, strtoll appears to call a function called
> strtoimax. I checked the version of MinGW I'm using the latest mingw
> runtime library and the mingw64 runtime library and they are all calling the
> exact same routine. The routine uses INTMAX_MAX which is set in stdint.h as
> 9223372036854775807LL.

Argh yes! The code is not detecting the overflow correctly - we must check
both for a maximum value and the ERANGE and not only the latter! Can you just
confirm that this fix works for you?

diff --git a/lib/http_chunks.c b/lib/http_chunks.c
index 47de958..83e3f0e 100644
--- a/lib/http_chunks.c
+++ b/lib/http_chunks.c
@@ -162,8 +162,8 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
          }

          ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16);
- if(errno == ERANGE)
- /* over or underflow is an error */
+ if((ch->datasize == CURL_OFF_T_MAX) && (errno == ERANGE))
+ /* overflow is an error */
            return CHUNKE_ILLEGAL_HEX;
          ch->state = CHUNK_LF; /* now wait for the CRLF */
        }

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-02-12