]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Address static analysis warnings.
authorMark Andrews <marka@isc.org>
Thu, 23 May 2013 04:14:26 +0000 (14:14 +1000)
committerMark Andrews <marka@isc.org>
Thu, 23 May 2013 04:15:03 +0000 (14:15 +1000)
  [ISC-Bugs #33510]

RELNOTES
minires/ns_parse.c
minires/ns_sign.c
minires/ns_verify.c
minires/res_findzonecut.c
minires/res_mkquery.c
minires/res_mkupdate.c
minires/res_update.c

index 251c979895567ef03de6775e60bc1caf363bfd41..cf356c4bad17fe51610367e48a4a5fae4a12ef8c 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -60,6 +60,9 @@ work on other platforms. Please report any problems and suggested fixes to
 
                        Changes since 4.2.5
 
+- Address static analysis warnings.
+  [ISC-Bugs #33510]
+
 - Silence benign static analysis warnings.
   [ISC-Bugs #33428]
 
index 95285fe14a57be7aa0d8461b56aecc4c179e0871..3f6e4ea64c4bbc7f2aac0166e9ad3ea14bae9cbf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -142,7 +142,7 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
        isc_result_t status;
 
        /* Make section right. */
-       if (section < 0 || section >= ns_s_max)
+       if (section >= ns_s_max)
                return ISC_R_NOTIMPLEMENTED;
        if (section != handle->_sect)
                setsection(handle, section);
index c61f14b5bc3982210d3d6d5c36e7eaedd9a74c48..25f4f8910d1d7aa198bc13b4c8bce3b695d6877e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1999-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -88,7 +88,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
        u_char *cp = msg + *msglen, *eob = msg + msgsize;
        u_char *lenp;
        u_char *name, *alg;
-       unsigned n;
+       int n;
        time_t timesigned;
 
        dst_init();
@@ -142,7 +142,7 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
        if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
                void *ctx;
                u_char buf[MAXDNAME], *cp2;
-               unsigned n;
+               int n;
 
                dst_sign_data(SIG_MODE_INIT, key, &ctx, NULL, 0, NULL, 0);
 
@@ -190,8 +190,10 @@ ns_sign(u_char *msg, unsigned *msglen, unsigned msgsize, int error, void *k,
                        PUTSHORT(0, cp2);       /* Top 16 bits of time */
                        PUTLONG(timesigned, cp2);
                }
-               dst_sign_data(SIG_MODE_UPDATE, key, &ctx,
-                             buf, (unsigned)(cp2-buf), NULL, 0);
+               n = dst_sign_data(SIG_MODE_UPDATE, key, &ctx,
+                                 buf, (unsigned)(cp2-buf), NULL, 0);
+               if (n < 0)
+                       return ISC_R_BADKEY;
 
                n = dst_sign_data(SIG_MODE_FINAL, key, &ctx, NULL, 0,
                                  sig, *siglen);
index 4e47f104ad8857c7b6e8fe30e95966acbb2bd4ef..793f8e8159637c233b2f8ee0d596627907cf7f12 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1999-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -148,13 +148,13 @@ ns_verify(u_char *msg, unsigned *msglen, void *k,
        char name[MAXDNAME], alg[MAXDNAME];
        u_char *recstart, *rdatastart;
        u_char *sigstart, *otherstart;
-       unsigned n;
+       int n;
        int error;
        u_int16_t type, length;
        u_int16_t fudge, sigfieldlen, id, otherfieldlen;
 
        dst_init();
-       if (msg == NULL || msglen == NULL || *msglen < 0)
+       if (msg == NULL || msglen == NULL)
                return ISC_R_INVALIDARG;
 
        eom = msg + *msglen;
index b66b91585794b2f239df21e7eb172772a6fc2a6c..3735477f0f93b538d887f7d2bb90af6238c794b5 100644 (file)
@@ -3,7 +3,7 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 1.18 2009/11/24 02:06:57 s
 #endif /* not lint */
 
 /*
- * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1999-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -296,7 +296,7 @@ get_soa(res_state statp, const char *dname, ns_class class,
                        int rdlen;
                        ns_rr rr;
 
-                       rcode = ns_parserr(&msg, sect, i, &rr) < 0;
+                       rcode = ns_parserr(&msg, sect, i, &rr);
                        if (rcode != ISC_R_SUCCESS) {
                                DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
                                         p_section(sect, ns_o_query), i));
@@ -591,7 +591,7 @@ do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
                DPRINTF(("do_query: res_nsend returned 0"));
                return ISC_R_NOTFOUND;
        }
-       if (ns_initparse((u_char *)resp, n, msg) < 0) {
+       if (ns_initparse((u_char *)resp, n, msg) != ISC_R_SUCCESS) {
                DPRINTF(("do_query: ns_initparse failed"));
                return ISC_R_NOSPACE;
        }
index d8ccdac2d9ce05676097eecae27f17dbd78e0c0a..d24a177b23f7807547ebf4b3e1a1ec59ff5fd2c6 100644 (file)
@@ -52,7 +52,7 @@
  */
 
 /*
- * Portions Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 2004,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Portions Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -139,8 +139,9 @@ res_nmkquery(res_state statp,
        switch (op) {
        case QUERY:     /*FALLTHROUGH*/
        case NS_NOTIFY_OP:
-               if ((buflen -= QFIXEDSZ) < 0)
+               if (buflen < QFIXEDSZ )
                        return ISC_R_NOSPACE;
+               buflen -= QFIXEDSZ;
                if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
                        return ISC_R_NOSPACE;
                cp += n;
@@ -155,6 +156,8 @@ res_nmkquery(res_state statp,
                /*
                 * Make an additional record for completion domain.
                 */
+               if (buflen < RRFIXEDSZ)
+                       return ISC_R_NOSPACE;
                buflen -= RRFIXEDSZ;
                n = dn_comp((const char *)data, cp, buflen, dnptrs, lastdnptr);
                if (n < 0)
index 5d21b12b56f445c8bb6b0151bf62ac8e14dcef29..ab2c3c9a352cdb2fee84959fc3237036b54c7c59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007-2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -108,7 +108,7 @@ res_nmkupdate(res_state statp,
        u_int16_t rtype, rclass;
        u_int32_t n1, rttl;
        u_char *dnptrs[20], **dpp, **lastdnptr;
-       unsigned certlen;
+       int certlen;
        int keylen;
        unsigned buflen = *blp;
        u_char *buf = (unsigned char *)bp;
index 7e91976c31cd0244d051e398a68630a4a0cee486..8311d04f26649f017789fbc703693bffb5bbeb78 100644 (file)
@@ -3,7 +3,7 @@ static const char rcsid[] = "$Id: res_update.c,v 1.17 2009/11/24 02:06:57 sar Ex
 #endif /* not lint */
 
 /*
- * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007,2009,2013 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -180,7 +180,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
  undone:
        /* Restore resolver's nameserver set. */
        statp->nscount = nscopy(statp->nsaddr_list, nsaddrs, nscount);
-       nscount = 0;
+
  done:
        if (zptr) {
                if ((zptr->z_flags & ZG_F_ZONESECTADDED) != 0)