diff options
author | Thomas Markwalder <tmark@isc.org> | 2014-08-28 09:17:30 -0400 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2014-08-28 09:17:30 -0400 |
commit | 505b61b0a75b91a0f604f22d6fc4bda7095d7ffc (patch) | |
tree | a5ffaf4a5c4deb03b672b7d42680c571a052faaa | |
parent | 997ec20120da937eae1c91a314d49ad3867c9d92 (diff) | |
download | isc-dhcp-505b61b0a75b91a0f604f22d6fc4bda7095d7ffc.tar.gz |
[v4_2] Corrects medium impact issues reported by Coverity.
Merges in rt36933
Fixed Conflicts:
server/dhcp.c -
changes for CID 753050 (31b97ba1bdd4ddf6dd593b434592d0e17f985d0f)
were not relevant
server/omapi.c -
changes for CID 1194735 (5bab149927ea57d0213e3a9f5d8f53ddc4a4bf56)
were not relevant
-rw-r--r-- | RELNOTES | 3 | ||||
-rw-r--r-- | common/options.c | 18 | ||||
-rw-r--r-- | common/parse.c | 8 | ||||
-rw-r--r-- | dst/dst_api.c | 2 | ||||
-rw-r--r-- | dst/prandom.c | 3 | ||||
-rw-r--r-- | omapip/test.c | 7 | ||||
-rw-r--r-- | omapip/trace.c | 6 | ||||
-rw-r--r-- | server/db.c | 2 | ||||
-rw-r--r-- | server/ddns.c | 11 | ||||
-rw-r--r-- | server/dhcpv6.c | 4 | ||||
-rw-r--r-- | server/failover.c | 7 |
11 files changed, 49 insertions, 22 deletions
@@ -46,6 +46,9 @@ by Eric Young (eay@cryptsoft.com). Changes since 4.2.7 - Addressed Coverity issues reported as of 07-31-2014: + [ISC-Bugs #36933] Corrects Coverity reported "medium" impact issues + +- Addressed Coverity issues reported as of 07-31-2014: [ISC-Bugs #36712] Corrects Coverity reported "high" impact issues Changes since 4.2.7rc1 diff --git a/common/options.c b/common/options.c index 170f10d3..9420b472 100644 --- a/common/options.c +++ b/common/options.c @@ -1849,6 +1849,15 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes) * of the last format type and we add 1 to * cover the entire first record. */ + + /* If format string had no valid entries prior to + * 'a' hunkinc will be 0. Ex: "a", "oa", "aA" */ + if (hunkinc == 0) { + log_error ("%s: invalid 'a' format: %s", + option->name, option->format); + return ("<error>"); + } + numhunk = ((len - hunksize) / hunkinc) + 1; len_used = hunksize + ((numhunk - 1) * hunkinc); } else { @@ -1856,6 +1865,15 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes) * It is an 'A' type array - we repeat the * entire record */ + + /* If format string had no valid entries prior to + * 'A' hunksize will be 0. Ex: "A", "oA", "foA" */ + if (hunksize == 0) { + log_error ("%s: invalid 'A' format: %s", + option->name, option->format); + return ("<error>"); + } + numhunk = len / hunksize; len_used = numhunk * hunksize; } diff --git a/common/parse.c b/common/parse.c index 5333704f..897fac34 100644 --- a/common/parse.c +++ b/common/parse.c @@ -5068,14 +5068,6 @@ int parse_expression (expr, cfile, lose, context, plhs, binop) tmp = (struct expression *)0; rhs = (struct expression *)0; - /* Recursions don't return until we have parsed the end of the - expression, so if we recursed earlier, we can now return what - we got. */ - if (next_op == expr_none) { - *expr = lhs; - return 1; - } - binop = next_op; goto new_rhs; } diff --git a/dst/dst_api.c b/dst/dst_api.c index f93ee810..30dc66f5 100644 --- a/dst/dst_api.c +++ b/dst/dst_api.c @@ -819,7 +819,7 @@ dst_key_to_buffer(DST_KEY *key, u_char *out_buff, unsigned buf_len) /* this function will extract the secret of HMAC into a buffer */ if(key == NULL) return (0); - if(key->dk_func != NULL && key->dk_func != NULL) { + if(key->dk_func != NULL && key->dk_func->to_dns_key != NULL) { len = key->dk_func->to_dns_key(key, out_buff, buf_len); if (len < 0) return (0); diff --git a/dst/prandom.c b/dst/prandom.c index ea02a275..7a24d332 100644 --- a/dst/prandom.c +++ b/dst/prandom.c @@ -492,8 +492,7 @@ digest_file(dst_work *work) if (i > 0) work->filled += i; } - else if (i > 0) - my_digest(work, buf, (unsigned)i); + my_digest(work, (const u_char *)name, strlen(name)); return (no + strlen(name)); } diff --git a/omapip/test.c b/omapip/test.c index e97a61fc..91831080 100644 --- a/omapip/test.c +++ b/omapip/test.c @@ -52,7 +52,12 @@ int main (int argc, char **argv) exit(1); } - omapi_init (); + status = omapi_init (); + if (status != ISC_R_SUCCESS) { + fprintf(stderr, "omapi_init failed: %s\n", + isc_result_totext(status)); + exit(1); + } if (argc > 1 && !strcmp (argv [1], "listen")) { if (argc < 3) { diff --git a/omapip/trace.c b/omapip/trace.c index 23e4e506..f4115c14 100644 --- a/omapip/trace.c +++ b/omapip/trace.c @@ -606,7 +606,9 @@ isc_result_t trace_get_next_packet (trace_type_t **ttp, paylen = tpkt -> length; if (paylen % 8) paylen += 8 - (tpkt -> length % 8); - if (paylen > (*bufmax)) { + + /* allocate a buffer if we need one or current buffer is too small */ + if ((*buf == NULL) || (paylen > (*bufmax))) { if ((*buf)) dfree ((*buf), MDL); (*bufmax) = ((paylen + 1023) & ~1023U); @@ -617,7 +619,7 @@ isc_result_t trace_get_next_packet (trace_type_t **ttp, return ISC_R_NOMEMORY; } } - + status = fread ((*buf), 1, paylen, traceinfile); if (status < paylen) { if (ferror (traceinfile)) diff --git a/server/db.c b/server/db.c index 82f3841f..aa42af7b 100644 --- a/server/db.c +++ b/server/db.c @@ -1181,7 +1181,7 @@ int new_lease_file () fail: lease_file_is_corrupt = db_validity; fdfail: - unlink (newfname); + (void)unlink (newfname); return 0; } diff --git a/server/ddns.c b/server/ddns.c index 64662dcc..b61c229f 100644 --- a/server/ddns.c +++ b/server/ddns.c @@ -236,10 +236,9 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old, goto out; } - buffer_allocate (&ddns_fwd_name.buffer, - ddns_hostname.len + ddns_domainname.len + 2, - MDL); - if (ddns_fwd_name.buffer) { + if (buffer_allocate (&ddns_fwd_name.buffer, + ddns_hostname.len + + ddns_domainname.len + 2, MDL)) { ddns_fwd_name.data = ddns_fwd_name.buffer->data; data_string_append (&ddns_fwd_name, &ddns_hostname); ddns_fwd_name.buffer->data[ddns_fwd_name.len] = '.'; @@ -447,8 +446,8 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old, } if (s1) { - buffer_allocate(&ddns_cb->rev_name.buffer, rev_name_len, MDL); - if (ddns_cb->rev_name.buffer != NULL) { + if (buffer_allocate(&ddns_cb->rev_name.buffer, + rev_name_len, MDL)) { struct data_string *rname = &ddns_cb->rev_name; rname->data = rname->buffer->data; diff --git a/server/dhcpv6.c b/server/dhcpv6.c index 729e4d35..c6f1cf7c 100644 --- a/server/dhcpv6.c +++ b/server/dhcpv6.c @@ -3201,6 +3201,8 @@ lease_compare(struct iasubopt *alpha, struct iasubopt *beta) { if (alpha->hard_lifetime_end_time < beta->hard_lifetime_end_time) return alpha; + else + return beta; default: log_fatal("Impossible condition at %s:%d.", MDL); @@ -4259,6 +4261,8 @@ prefix_compare(struct reply_state *reply, if (alpha->hard_lifetime_end_time < beta->hard_lifetime_end_time) return alpha; + else + return beta; default: log_fatal("Impossible condition at %s:%d.", MDL); diff --git a/server/failover.c b/server/failover.c index b39d2638..75fc8553 100644 --- a/server/failover.c +++ b/server/failover.c @@ -720,7 +720,10 @@ static isc_result_t do_a_failover_option (c, link) /* FT_DDNS* are special - one or two bytes of status followed by the client FQDN. */ - if (ft_options [option_code].type == FT_DDNS1 || + + /* Note: FT_DDNS* option support appears to be incomplete. + ISC-Bugs #36996 has been opened to address this. */ + if (ft_options [option_code].type == FT_DDNS || ft_options [option_code].type == FT_DDNS1) { ddns_fqdn_t *ddns = ((ddns_fqdn_t *) @@ -2277,6 +2280,8 @@ isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *state, switch (new_state) { case recover_done: log_error("Both servers have entered recover-done!"); + /* Fall through and tranistion to normal anyway */ + case normal: dhcp_failover_set_state (state, normal); break; |