Commit 88acc642 authored by Thomas Markwalder's avatar Thomas Markwalder

[#9,!11] Removed length checks on data_string_forget calls

client/dhc6.c
    dhc6_parse_ia_na() - 1 occurrence
    dhc6_parse_ia_ta() - 1 occurrence
    dhc6_parse_ia_pd() - 1 occurrence
    dhc6_parse_prefixes() - 1 occurrence
    dhc6_lease_destroy() - 1 occurrence

client/dhclient.c
    client_option_envadd() - 1 occurrence

common/options.c
    store_options() - 1 occurrence
    fqdn_option_space_encapsulate() - 1 occurrence
    fqdn6_option_space_encapsulate() - 1 occurrence
    parse_vendor_option() - 1 occurrence

server/class.c
    check_collection() - 1 occurrence

server/dhcp.c
    locate_network()  - 1 occurrence

server/dhcpleasequery.c
    valid_query_msg() - 3 occurrences

server/dhcpv6.c
    valid_client_msg() - 2 occurrences
    valid_client_resp() - 2 occurrences
    valid_client_info_req() - 1 occurrence
parent c1155d29
......@@ -816,8 +816,7 @@ dhc6_parse_ia_na(struct dhc6_ia **pia, struct packet *packet,
} else {
log_error("Invalid IA_NA option cache.");
dfree(ia, MDL);
if (ds.len != 0)
data_string_forget(&ds, MDL);
data_string_forget(&ds, MDL);
return ISC_R_UNEXPECTED;
}
}
......@@ -919,8 +918,7 @@ dhc6_parse_ia_ta(struct dhc6_ia **pia, struct packet *packet,
} else {
log_error("Invalid IA_TA option cache.");
dfree(ia, MDL);
if (ds.len != 0)
data_string_forget(&ds, MDL);
data_string_forget(&ds, MDL);
return ISC_R_UNEXPECTED;
}
}
......@@ -1042,8 +1040,7 @@ dhc6_parse_ia_pd(struct dhc6_ia **pia, struct packet *packet,
} else {
log_error("Invalid IA_PD option cache.");
dfree(ia, MDL);
if (ds.len != 0)
data_string_forget(&ds, MDL);
data_string_forget(&ds, MDL);
return ISC_R_UNEXPECTED;
}
}
......@@ -1158,8 +1155,7 @@ dhc6_parse_addrs(struct dhc6_addr **paddr, struct packet *packet,
} else {
log_error("Invalid IAADDR option cache.");
dfree(addr, MDL);
if (ds.len != 0)
data_string_forget(&ds, MDL);
data_string_forget(&ds, MDL);
return ISC_R_UNEXPECTED;
}
}
......@@ -1283,8 +1279,7 @@ dhc6_parse_prefixes(struct dhc6_addr **ppfx, struct packet *packet,
} else {
log_error("Invalid IAPREFIX option cache.");
dfree(pfx, MDL);
if (ds.len != 0)
data_string_forget(&ds, MDL);
data_string_forget(&ds, MDL);
return ISC_R_UNEXPECTED;
}
}
......@@ -1306,9 +1301,7 @@ dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line)
}
lease = *src;
if (lease->server_id.len != 0)
data_string_forget(&lease->server_id, file, line);
data_string_forget(&lease->server_id, file, line);
for (ia = lease->bindings ; ia != NULL ; ia = nia) {
nia = ia->next;
......
......@@ -4179,9 +4179,10 @@ void client_option_envadd (struct option_cache *oc,
"option - discarded",
name);
}
data_string_forget (&data, MDL);
}
}
data_string_forget (&data, MDL);
}
}
......
......@@ -1406,8 +1406,9 @@ store_options(int *ocount,
(option_space_encapsulate
(&encapsulation, packet, lease, client_state,
in_options, cfg_options, scope, &name));
data_string_forget (&name, MDL);
}
data_string_forget (&name, MDL);
}
}
......@@ -3437,8 +3438,7 @@ int fqdn_option_space_encapsulate (result, packet, lease, client_state,
}
exit:
for (i = 1; i <= FQDN_SUBOPTION_COUNT; i++) {
if (results [i].len)
data_string_forget (&results [i], MDL);
data_string_forget (&results[i], MDL);
}
buffer_dereference (&bp, MDL);
if (!status)
......@@ -3597,8 +3597,7 @@ fqdn6_option_space_encapsulate(struct data_string *result,
exit:
for (i = 1 ; i <= FQDN_SUBOPTION_COUNT ; i++) {
if (results[i].len)
data_string_forget(&results[i], MDL);
data_string_forget(&results[i], MDL);
}
return rval;
......@@ -4498,8 +4497,10 @@ void parse_vendor_option(packet, lease, client_state, in_options,
in_options, out_options, scope, oc, MDL);
/* No name, all done */
if (name.len == 0)
if (name.len == 0) {
data_string_forget(&name, MDL);
return;
}
/* Get any vendor option information from the request */
oc = lookup_option(&dhcp_universe, in_options, code);
......
......@@ -174,7 +174,6 @@ int check_collection (packet, lease, collection)
}
data_string_copy (&nc -> hash_string, &data,
MDL);
data_string_forget (&data, MDL);
if (!class -> hash)
class_new_hash(&class->hash,
SCLASS_HASH_SIZE, MDL);
......@@ -186,6 +185,8 @@ int check_collection (packet, lease, collection)
classify (packet, nc);
class_dereference (&nc, MDL);
}
data_string_forget (&data, MDL);
}
}
return matched;
......
......@@ -5373,13 +5373,12 @@ int locate_network (packet)
&global_scope, oc, MDL)) {
return 0;
}
if (data.len == 0) {
return 0;
}
if (data.len != 4) {
data_string_forget (&data, MDL);
return 0;
}
ia.len = 4;
memcpy (ia.iabuf, data.data, 4);
data_string_forget (&data, MDL);
......
......@@ -873,15 +873,9 @@ valid_query_msg(struct lq6_state *lq) {
exit:
if (!ret_val) {
if (lq->client_id.len > 0) {
data_string_forget(&lq->client_id, MDL);
}
if (lq->server_id.len > 0) {
data_string_forget(&lq->server_id, MDL);
}
if (lq->lq_query.len > 0) {
data_string_forget(&lq->lq_query, MDL);
}
data_string_forget(&lq->client_id, MDL);
data_string_forget(&lq->server_id, MDL);
data_string_forget(&lq->lq_query, MDL);
}
return ret_val;
}
......
......@@ -632,13 +632,9 @@ valid_client_msg(struct packet *packet, struct data_string *client_id) {
ret_val = 1;
exit:
if (data.len > 0) {
data_string_forget(&data, MDL);
}
data_string_forget(&data, MDL);
if (!ret_val) {
if (client_id->len > 0) {
data_string_forget(client_id, MDL);
}
data_string_forget(client_id, MDL);
}
return ret_val;
}
......@@ -723,12 +719,8 @@ valid_client_resp(struct packet *packet,
exit:
if (!ret_val) {
if (server_id->len > 0) {
data_string_forget(server_id, MDL);
}
if (client_id->len > 0) {
data_string_forget(client_id, MDL);
}
data_string_forget(server_id, MDL);
data_string_forget(client_id, MDL);
}
return ret_val;
}
......@@ -840,9 +832,7 @@ valid_client_info_req(struct packet *packet, struct data_string *server_id) {
exit:
if (!ret_val) {
if (server_id->len > 0) {
data_string_forget(server_id, MDL);
}
data_string_forget(server_id, MDL);
}
return ret_val;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment