diff options
author | Shawn Routhier <sar@isc.org> | 2012-10-16 15:05:24 -0700 |
---|---|---|
committer | Shawn Routhier <sar@isc.org> | 2012-10-16 15:05:24 -0700 |
commit | 0f750c4fb19823f622cfde356ac7f7aa2c9a3427 (patch) | |
tree | fea3ccc473e35832e12a0a3d0a576ea9b2174846 /server | |
parent | 881442e20f455fb1dc21600390cc5aecae08fd72 (diff) | |
download | isc-dhcp-0f750c4fb19823f622cfde356ac7f7aa2c9a3427.tar.gz |
[master]
[rt23833]
Clean up a number of items identified by the Coverity
static analysis tool. Runs courtesy of Red Hat.
Diffstat (limited to 'server')
-rw-r--r-- | server/class.c | 5 | ||||
-rw-r--r-- | server/confpars.c | 13 | ||||
-rw-r--r-- | server/db.c | 3 | ||||
-rw-r--r-- | server/ddns.c | 7 | ||||
-rw-r--r-- | server/dhcpv6.c | 9 | ||||
-rw-r--r-- | server/failover.c | 4 | ||||
-rw-r--r-- | server/ldap.c | 2 | ||||
-rw-r--r-- | server/mdb.c | 31 | ||||
-rw-r--r-- | server/omapi.c | 4 |
9 files changed, 41 insertions, 37 deletions
diff --git a/server/class.c b/server/class.c index 2f92255e..b8eac87c 100644 --- a/server/class.c +++ b/server/class.c @@ -3,7 +3,8 @@ Handling for client classes. */ /* - * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1998-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -185,7 +186,7 @@ int check_collection (packet, lease, collection) } memset (nc -> billed_leases, 0, (nc -> lease_limit * - sizeof nc -> billed_leases)); + sizeof (struct lease *))); } data_string_copy (&nc -> hash_string, &data, MDL); diff --git a/server/confpars.c b/server/confpars.c index 1c9c4802..1c492343 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -1046,7 +1046,6 @@ void parse_failover_peer (cfile, group, type) if (hba_len != 32) { parse_warn (cfile, "HBA must be exactly 32 bytes."); - dfree (hba, MDL); break; } make_hba: @@ -2123,7 +2122,7 @@ int parse_class_declaration (cp, cfile, group, type) log_fatal ("no memory for billing"); memset (class -> billed_leases, 0, (class -> lease_limit * - sizeof class -> billed_leases)); + sizeof (struct lease *))); } data_string_copy (&class -> hash_string, &data, MDL); if (!pc -> hash && @@ -2319,7 +2318,7 @@ int parse_class_declaration (cp, cfile, group, type) log_fatal ("no memory for billed leases."); memset (class -> billed_leases, 0, (class -> lease_limit * - sizeof class -> billed_leases)); + sizeof (struct lease *))); have_billing_classes = 1; parse_semi (cfile); } else { @@ -2383,7 +2382,9 @@ void parse_shared_net_declaration (cfile, group) if (status != ISC_R_SUCCESS) log_fatal ("Can't allocate shared subnet: %s", isc_result_totext (status)); - clone_group (&share -> group, group, MDL); + if (clone_group (&share -> group, group, MDL) == 0) { + log_fatal ("Can't clone group for shared net"); + } shared_network_reference (&share -> group -> shared_network, share, MDL); @@ -2794,9 +2795,9 @@ void parse_group_declaration (cfile, group) val, isc_result_totext(status)); group_reference(&t->group, g, MDL); t->name = name; + /* no need to include deletedp as it's handled above */ t->flags = ((staticp ? GROUP_OBJECT_STATIC : 0) | - (dynamicp ? GROUP_OBJECT_DYNAMIC : 0) | - (deletedp ? GROUP_OBJECT_DELETED : 0)); + (dynamicp ? GROUP_OBJECT_DYNAMIC : 0)); supersede_group(t, 0); } if (t != NULL) diff --git a/server/db.c b/server/db.c index 5be1684a..de185293 100644 --- a/server/db.c +++ b/server/db.c @@ -66,10 +66,9 @@ write_binding_scope(FILE *db_file, struct binding *bnd, char *prepend) { errno = 0; fprintf(db_file, "%sset %s = \"%s\";", prepend, bnd->name, s); + dfree(s, MDL); if (errno) return ISC_R_FAILURE; - - dfree(s, MDL); } else { return ISC_R_FAILURE; } diff --git a/server/ddns.c b/server/ddns.c index 90217bd9..80418721 100644 --- a/server/ddns.c +++ b/server/ddns.c @@ -1093,7 +1093,12 @@ ddns_update_lease_ptr(struct lease *lease, { char ddns_address[MAX_ADDRESS_STRING_LEN]; sprintf(ddns_address, "unknown"); - if (ddns_cb) { + if (ddns_cb == NULL) { + log_info("%s(%d): No control block for lease update", + file, line); + return (ISC_R_FAILURE); + } + else { strncpy(ddns_address, piaddr(ddns_cb->address), MAX_ADDRESS_STRING_LEN); } diff --git a/server/dhcpv6.c b/server/dhcpv6.c index 12d31fca..f94ea0bd 100644 --- a/server/dhcpv6.c +++ b/server/dhcpv6.c @@ -572,6 +572,7 @@ valid_client_info_req(struct packet *packet, struct data_string *server_id) { ret_val = 0; memset(server_id, 0, sizeof(*server_id)); + memset(&client_id, 0, sizeof(client_id)); /* * Make a string that we can print out to give more @@ -2680,9 +2681,11 @@ find_client_temporaries(struct reply_state *reply) { if (status != ISC_R_SUCCESS) { goto cleanup; } - if (reply->lease != NULL) { - iasubopt_dereference(&reply->lease, MDL); - } + /* + * reply->lease can't be null as we use it above + * add check if that changes + */ + iasubopt_dereference(&reply->lease, MDL); } cleanup: diff --git a/server/failover.c b/server/failover.c index 56b07aa9..e0a416e2 100644 --- a/server/failover.c +++ b/server/failover.c @@ -5046,7 +5046,7 @@ failover_lease_is_better(dhcp_failover_state_t *state, struct lease *lease, isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *state, failover_message_t *msg) { - struct lease *lt, *lease; + struct lease *lt = NULL, *lease = NULL; struct iaddr ia; int reason = FTR_MISC_REJECT; const char *message; @@ -5067,8 +5067,6 @@ isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *state, ia.len = sizeof msg -> assigned_addr; memcpy (ia.iabuf, &msg -> assigned_addr, ia.len); - lease = (struct lease *)0; - lt = (struct lease *)0; if (!find_lease_by_ip_addr (&lease, ia, MDL)) { message = "unknown IP address"; reason = FTR_ILLEGAL_IP_ADDR; diff --git a/server/ldap.c b/server/ldap.c index 5003228e..8a7d6955 100644 --- a/server/ldap.c +++ b/server/ldap.c @@ -1988,7 +1988,7 @@ find_subclass_in_ldap (struct class *class, struct class **newclass, return (0); } memset ((*newclass)->billed_leases, 0, - ((*newclass)->lease_limit * sizeof (*newclass)->billed_leases)); + ((*newclass)->lease_limit * sizeof (struct lease *))); } data_string_copy (&(*newclass)->hash_string, data, MDL); diff --git a/server/mdb.c b/server/mdb.c index 3867ba58..18378b3b 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -308,16 +308,13 @@ isc_result_t enter_host (hd, dynamicp, commit) /* See if there's a statement that sets the client identifier. This is a kludge - the client identifier really shouldn't be set with an executable statement. */ - esp = (struct executable_statement *)0; - if (executable_statement_foreach (hd -> group -> statements, + esp = NULL; + if (executable_statement_foreach (hd->group->statements, find_uid_statement, &esp, 0)) { - evaluate_option_cache (&hd -> client_identifier, - (struct packet *)0, - (struct lease *)0, - (struct client_state *)0, - (struct option_state *)0, - (struct option_state *)0, &global_scope, - esp -> data.option, MDL); + (void) evaluate_option_cache (&hd->client_identifier, + NULL, NULL, NULL, NULL, NULL, + &global_scope, + esp->data.option, MDL); } /* If we got a client identifier, hash this entry by @@ -1422,10 +1419,11 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) void make_binding_state_transition (struct lease *lease) { + #if defined (FAILOVER_PROTOCOL) dhcp_failover_state_t *peer; - if (lease && lease -> pool && lease -> pool -> failover_peer) + if (lease -> pool && lease -> pool -> failover_peer) peer = lease -> pool -> failover_peer; else peer = (dhcp_failover_state_t *)0; @@ -1572,17 +1570,18 @@ void make_binding_state_transition (struct lease *lease) case FTS_RELEASED: case FTS_ABANDONED: case FTS_RESET: - lease -> next_binding_state = FTS_FREE; + lease->next_binding_state = FTS_FREE; #if defined(FAILOVER_PROTOCOL) /* If we are not in partner_down, leases don't go from EXPIRED to FREE on a timeout - only on an update. If we're in partner_down, they expire at mclt past the time we entered partner_down. */ - if (lease -> pool -> failover_peer && - lease -> pool -> failover_peer -> me.state == partner_down) - lease -> tsfp = - (lease -> pool -> failover_peer -> me.stos + - lease -> pool -> failover_peer -> mclt); + if ((lease->pool != NULL) && + (lease->pool->failover_peer != NULL) && + (lease->pool->failover_peer->me.state == partner_down)) + lease->tsfp = + (lease->pool->failover_peer->me.stos + + lease->pool->failover_peer->mclt); #endif /* FAILOVER_PROTOCOL */ break; diff --git a/server/omapi.c b/server/omapi.c index 19b3847c..5901cc55 100644 --- a/server/omapi.c +++ b/server/omapi.c @@ -1690,7 +1690,6 @@ isc_result_t dhcp_pool_signal_handler (omapi_object_t *h, { /* h should point to (struct pool *) */ isc_result_t status; - int updatep = 0; if (h -> type != dhcp_type_pool) return DHCP_R_INVALIDARG; @@ -1704,8 +1703,7 @@ isc_result_t dhcp_pool_signal_handler (omapi_object_t *h, if (status == ISC_R_SUCCESS) return status; } - if (updatep) - return ISC_R_SUCCESS; + return ISC_R_NOTFOUND; } |