From: Mark Andrews Date: Thu, 23 May 2013 04:14:26 +0000 (+1000) Subject: - Address static analysis warnings. X-Git-Tag: v4_3_0a1~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0a10f6ac36616ddb0b287f785d2760473721d78;p=thirdparty%2Fdhcp.git - Address static analysis warnings. [ISC-Bugs #33510] --- diff --git a/RELNOTES b/RELNOTES index 251c97989..cf356c4ba 100644 --- 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] diff --git a/minires/ns_parse.c b/minires/ns_parse.c index 95285fe14..3f6e4ea64 100644 --- a/minires/ns_parse.c +++ b/minires/ns_parse.c @@ -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); diff --git a/minires/ns_sign.c b/minires/ns_sign.c index c61f14b5b..25f4f8910 100644 --- a/minires/ns_sign.c +++ b/minires/ns_sign.c @@ -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); diff --git a/minires/ns_verify.c b/minires/ns_verify.c index 4e47f104a..793f8e815 100644 --- a/minires/ns_verify.c +++ b/minires/ns_verify.c @@ -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; diff --git a/minires/res_findzonecut.c b/minires/res_findzonecut.c index b66b91585..3735477f0 100644 --- a/minires/res_findzonecut.c +++ b/minires/res_findzonecut.c @@ -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; } diff --git a/minires/res_mkquery.c b/minires/res_mkquery.c index d8ccdac2d..d24a177b2 100644 --- a/minires/res_mkquery.c +++ b/minires/res_mkquery.c @@ -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) diff --git a/minires/res_mkupdate.c b/minires/res_mkupdate.c index 5d21b12b5..ab2c3c9a3 100644 --- a/minires/res_mkupdate.c +++ b/minires/res_mkupdate.c @@ -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; diff --git a/minires/res_update.c b/minires/res_update.c index 7e91976c3..8311d04f2 100644 --- a/minires/res_update.c +++ b/minires/res_update.c @@ -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)