]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bugfix for assertion in httpHeaderFindEntry(). The caller,
authorwessels <>
Sat, 6 May 2006 00:16:26 +0000 (00:16 +0000)
committerwessels <>
Sat, 6 May 2006 00:16:26 +0000 (00:16 +0000)
HttpMsg::hdrCacheInit() was assuming that the content length header
is always present in the HTTP reply.

To fix I copied httpHeaderGetSize() from squid-2 code.  For now
this version of httpHeaderGetSize() is basically the same as
httpHeaderGetInt(), except that it checks to see if the header
exists.  If not, it returns -1.

src/HttpHeader.cc
src/HttpMsg.cc
src/protos.h

index c0cbd86bfcd19902a7dea2ee2162389379ad4d4f..94e4ad2ed4216def3c1dc47cdedfd47454f0087d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.cc,v 1.112 2006/04/22 05:29:18 robertc Exp $
+ * $Id: HttpHeader.cc,v 1.113 2006/05/05 18:16:26 wessels Exp $
  *
  * DEBUG: section 55    HTTP Header
  * AUTHOR: Alex Rousskov
@@ -1118,6 +1118,27 @@ httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id)
     return -1;
 }
 
+/*
+ * This is copied from Squid-2 code, which uses squid_off_t instead
+ * of int, and ftSize instead of ftInt
+ */
+int
+httpHeaderGetSize(const HttpHeader * hdr, http_hdr_type id)
+{
+    HttpHeaderEntry *e;
+    int value = -1;
+    int ok;
+    assert_eid(id);
+    assert(Headers[id].type == ftInt);         /* must be of an appropriate type */
+
+    if ((e = httpHeaderFindEntry(hdr, id))) {
+        ok = httpHeaderParseSize(e->value.buf(), &value);
+        httpHeaderNoteParsedEntry(e->id, e->value, !ok);
+    }
+
+    return value;
+}
+
 time_t
 httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id)
 {
index 8b7fac545a05594af3aaa6c7f5b0f86fa0eebf56..6c11023f73a8f7cdef2dcc0b7673016ac4ab3a23 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.cc,v 1.26 2006/04/18 12:25:50 robertc Exp $
+ * $Id: HttpMsg.cc,v 1.27 2006/05/05 18:16:26 wessels Exp $
  *
  * DEBUG: section 74    HTTP Message
  * AUTHOR: Alex Rousskov
@@ -338,7 +338,7 @@ void HttpMsg::packInto(Packer *p, bool full_uri) const
 
 void HttpMsg::hdrCacheInit()
 {
-    content_length = httpHeaderGetInt(&header, HDR_CONTENT_LENGTH);
+    content_length = httpHeaderGetSize(&header, HDR_CONTENT_LENGTH);
     assert(NULL == cache_control);
     cache_control = httpHeaderGetCc(&header);
 }
index 21f20d88cad92fcc330499dc1d7dc17747dd8bc2..3d6c1549606743787e9872ffa6ac09a9b7d5a3fb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.524 2006/04/29 13:53:16 serassio Exp $
+ * $Id: protos.h,v 1.525 2006/05/05 18:16:26 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -349,6 +349,7 @@ class HttpHdrRange;
 SQUIDCEXTERN void httpHeaderPutRange(HttpHeader * hdr, const HttpHdrRange * range);
 SQUIDCEXTERN void httpHeaderPutExt(HttpHeader * hdr, const char *name, const char *value);
 SQUIDCEXTERN int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id);
+SQUIDCEXTERN int httpHeaderGetSize(const HttpHeader * hdr, http_hdr_type id);
 SQUIDCEXTERN time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id);
 SQUIDCEXTERN TimeOrTag httpHeaderGetTimeOrTag(const HttpHeader * hdr, http_hdr_type id);
 SQUIDCEXTERN HttpHdrCc *httpHeaderGetCc(const HttpHeader * hdr);