]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Various errors detected by Coverity scan
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 19 Mar 2009 14:44:22 +0000 (03:44 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 19 Mar 2009 14:44:22 +0000 (03:44 +1300)
lib/rfc2617.c
src/auth/basic/auth_basic.cc
src/htcp.cc
src/ip/IpAddress.cc

index f5c50d40048edfdb4885c0b4924710e6e49a2586..324d48078ef1c9229a9ad685cae26609593adb27 100644 (file)
@@ -94,6 +94,11 @@ CvtBin(const HASHHEX Hex, HASH Bin)
         else
             Bin[i / 2] |= n;
     }
+/* FIXME: Coverity detects the below as dead code.
+  Why? :: right here i == 32 
+    which means the first step of the for loop makes i==16
+    and cannot be < HASHLEN (which is also 16)
+*/
     for (i = i / 2; i < HASHLEN; i++) {
         Bin[i] = '\0';
     }
index 4fdee3b5250110ecfb80ebf2d05df51db18dce1f..9aa07bb53a7126a8902e400123bdb88e8f50c6b6 100644 (file)
@@ -143,9 +143,8 @@ int
 AuthBasicUserRequest::authenticated() const
 {
     BasicUser const *basic_auth = dynamic_cast<BasicUser const *>(user());
-    assert (basic_auth != NULL);
 
-    if (basic_auth->authenticated())
+    if (basic_auth && basic_auth->authenticated())
         return 1;
 
     return 0;
index ee54e9fae8c8b414343c0674475b41b75b6317f1..d0125207df3548cdd16ec05a9bd594be87f5301a 100644 (file)
@@ -881,19 +881,20 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, IpAddr
         stuff.S.uri = spec->uri;
         stuff.S.version = spec->version;
         stuff.S.req_hdrs = spec->req_hdrs;
-        hdr.putInt(HDR_AGE,
-                   e->timestamp <= squid_curtime ?
-                   squid_curtime - e->timestamp : 0);
+        if(e)
+            hdr.putInt(HDR_AGE, (e->timestamp <= squid_curtime ? (squid_curtime - e->timestamp) : 0) );
+        else
+            hdr.putInt(HDR_AGE, 0);
         hdr.packInto(&p);
         stuff.D.resp_hdrs = xstrdup(mb.buf);
         debugs(31, 3, "htcpTstReply: resp_hdrs = {" << stuff.D.resp_hdrs << "}");
         mb.reset();
         hdr.reset();
 
-        if (e->expires > -1)
+        if (e && e->expires > -1)
             hdr.putTime(HDR_EXPIRES, e->expires);
 
-        if (e->lastmod > -1)
+        if (e && e->lastmod > -1)
             hdr.putTime(HDR_LAST_MODIFIED, e->lastmod);
 
         hdr.packInto(&p);
index 2cf158280fe1601d6c223e5752b39e3b8ffa0704..1fc77b1f55ef44a7b6b85de9f93f3bfcc081ffcd 100644 (file)
@@ -651,10 +651,8 @@ IpAddress::IpAddress(IpAddress *s)
 
 IpAddress& IpAddress::operator =(IpAddress *s)
 {
-    IpAddress *tmp = NULL;
     if (!s) return *this;
-    tmp = dynamic_cast<IpAddress*>(s);
-    if (!tmp) return *this;
+    IpAddress *tmp = static_cast<IpAddress*>(s);
     return operator=(*tmp);
 }