]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Christos Tsantilos <chtsanti@users.sourceforge.net>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Sat, 12 Apr 2008 14:00:53 +0000 (08:00 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Sat, 12 Apr 2008 14:00:53 +0000 (08:00 -0600)
Bug 2286: assertion failed: HttpHdrContRange.cc:100: "spec->length >= 0"

Moves the assertion check for spec->length in function
httpHdrRangeRespSpecParseInit  exactly after the spec->length copmuted.

Also Fix of a possible  misuse of errno in httpHeaderParseOffset function
The errno before used with strtol function must set to "0".

src/HttpHdrContRange.cc
src/HttpHeaderTools.cc

index e3a04a6a04041d8916dbdb8d15ef2eee0075cd44..cb6e9c70f29f7915be5f100c96f34e4e85fd447e 100644 (file)
@@ -94,11 +94,10 @@ httpHdrRangeRespSpecParseInit(HttpHdrRangeSpec * spec, const char *field, int fl
             return 0;
 
         spec->length = size_diff(last_pos + 1, spec->offset);
+        /* Ensure typecast is safe */
+        assert (spec->length >= 0);
     }
 
-    /* Ensure typecast is safe */
-    assert (spec->length >= 0);
-
     /* we managed to parse, check if the result makes sence */
     if (known_spec(spec->length) && spec->length == 0) {
         debugs(68, 2, "invalid range (" << spec->offset << " += " <<
index e9f3b3f6145ea8873c88281482edb8f8e2e699b9..17ac5322942e58fb0dd381428b5d971aa44209e6 100644 (file)
@@ -333,6 +333,7 @@ httpHeaderParseInt(const char *start, int *value)
 int
 httpHeaderParseOffset(const char *start, int64_t * value)
 {
+    errno = 0;
     int64_t res = strtoll(start, NULL, 10);
     if (!res && EINVAL == errno)       /* maybe not portable? */
        return 0;