From 99203419dd0585cfd24707f57ed4b74eba53e8ba Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 12 Apr 2008 08:00:53 -0600 Subject: [PATCH] Author: Christos Tsantilos 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 | 5 ++--- src/HttpHeaderTools.cc | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HttpHdrContRange.cc b/src/HttpHdrContRange.cc index e3a04a6a04..cb6e9c70f2 100644 --- a/src/HttpHdrContRange.cc +++ b/src/HttpHdrContRange.cc @@ -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 << " += " << diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index e9f3b3f614..17ac532294 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -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; -- 2.47.2