mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-31 01:04:03 -05:00
FST: Use EINVAL more consistently as a negative return value
There was a mix of EINVAL and -EINVAL returns through the FST implementation. Make this more consistent by always returning -EINVAL in error cases. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a0f04da517
commit
73664e0985
@ -842,13 +842,13 @@ int fst_read_next_text_param(const char *params, char *buf, size_t buflen,
|
|||||||
char *cur_dest;
|
char *cur_dest;
|
||||||
|
|
||||||
if (buflen <= 1)
|
if (buflen <= 1)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
*endp = (char *) params;
|
*endp = (char *) params;
|
||||||
while (isspace(**endp))
|
while (isspace(**endp))
|
||||||
(*endp)++;
|
(*endp)++;
|
||||||
if (!**endp)
|
if (!**endp)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
max_chars_to_copy = buflen - 1;
|
max_chars_to_copy = buflen - 1;
|
||||||
/* We need 1 byte for the terminating zero */
|
/* We need 1 byte for the terminating zero */
|
||||||
@ -895,7 +895,7 @@ int fst_parse_attach_command(const char *cmd, char *ifname, size_t ifname_size,
|
|||||||
if (fst_read_next_text_param(cmd, ifname, ifname_size, &endp) ||
|
if (fst_read_next_text_param(cmd, ifname, ifname_size, &endp) ||
|
||||||
fst_read_next_text_param(endp, cfg->group_id, sizeof(cfg->group_id),
|
fst_read_next_text_param(endp, cfg->group_id, sizeof(cfg->group_id),
|
||||||
&endp))
|
&endp))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
cfg->llt = FST_DEFAULT_LLT_CFG_VALUE;
|
cfg->llt = FST_DEFAULT_LLT_CFG_VALUE;
|
||||||
cfg->priority = 0;
|
cfg->priority = 0;
|
||||||
@ -928,20 +928,17 @@ int fst_parse_detach_command(const char *cmd, char *ifname, size_t ifname_size)
|
|||||||
{
|
{
|
||||||
char *endp;
|
char *endp;
|
||||||
|
|
||||||
if (fst_read_next_text_param(cmd, ifname, ifname_size, &endp))
|
return fst_read_next_text_param(cmd, ifname, ifname_size, &endp);
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* fst iface_detach */
|
|
||||||
int fst_iface_detach(const char *ifname)
|
int fst_iface_detach(const char *ifname)
|
||||||
{
|
{
|
||||||
struct fst_group *g;
|
struct fst_group *g;
|
||||||
struct fst_iface *f;
|
|
||||||
|
|
||||||
foreach_fst_group(g) {
|
foreach_fst_group(g) {
|
||||||
|
struct fst_iface *f;
|
||||||
|
|
||||||
f = fst_group_get_iface_by_name(g, ifname);
|
f = fst_group_get_iface_by_name(g, ifname);
|
||||||
if (f) {
|
if (f) {
|
||||||
fst_detach(f);
|
fst_detach(f);
|
||||||
@ -949,5 +946,5 @@ int fst_iface_detach(const char *ifname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -1323,25 +1323,25 @@ static int get_group_fill_session(struct fst_group **g, struct fst_session *s)
|
|||||||
*g = dl_list_first(&fst_global_groups_list,
|
*g = dl_list_first(&fst_global_groups_list,
|
||||||
struct fst_group, global_groups_lentry);
|
struct fst_group, global_groups_lentry);
|
||||||
if (!*g)
|
if (!*g)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
s->data.new_iface = dl_list_first(&(*g)->ifaces, struct fst_iface,
|
s->data.new_iface = dl_list_first(&(*g)->ifaces, struct fst_iface,
|
||||||
group_lentry);
|
group_lentry);
|
||||||
if (!s->data.new_iface)
|
if (!s->data.new_iface)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
s->data.old_iface = dl_list_entry(s->data.new_iface->group_lentry.next,
|
s->data.old_iface = dl_list_entry(s->data.new_iface->group_lentry.next,
|
||||||
struct fst_iface, group_lentry);
|
struct fst_iface, group_lentry);
|
||||||
if (!s->data.old_iface)
|
if (!s->data.old_iface)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
old_addr = fst_iface_get_peer_first(s->data.old_iface, &ctx, TRUE);
|
old_addr = fst_iface_get_peer_first(s->data.old_iface, &ctx, TRUE);
|
||||||
if (!old_addr)
|
if (!old_addr)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
new_addr = fst_iface_get_peer_first(s->data.new_iface, &ctx, TRUE);
|
new_addr = fst_iface_get_peer_first(s->data.new_iface, &ctx, TRUE);
|
||||||
if (!new_addr)
|
if (!new_addr)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
os_memcpy(s->data.old_peer_addr, old_addr, ETH_ALEN);
|
os_memcpy(s->data.old_peer_addr, old_addr, ETH_ALEN);
|
||||||
os_memcpy(s->data.new_peer_addr, new_addr, ETH_ALEN);
|
os_memcpy(s->data.new_peer_addr, new_addr, ETH_ALEN);
|
||||||
@ -1366,10 +1366,10 @@ int fst_test_req_send_fst_request(const char *params)
|
|||||||
|
|
||||||
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
||||||
if (!is_valid)
|
if (!is_valid)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_group_fill_session(&g, &s))
|
if (get_group_fill_session(&g, &s))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
req.action = FST_ACTION_SETUP_REQUEST;
|
req.action = FST_ACTION_SETUP_REQUEST;
|
||||||
req.dialog_token = g->dialog_token;
|
req.dialog_token = g->dialog_token;
|
||||||
@ -1417,10 +1417,10 @@ int fst_test_req_send_fst_response(const char *params)
|
|||||||
|
|
||||||
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
||||||
if (!is_valid)
|
if (!is_valid)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_group_fill_session(&g, &s))
|
if (get_group_fill_session(&g, &s))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
status_code = WLAN_STATUS_SUCCESS;
|
status_code = WLAN_STATUS_SUCCESS;
|
||||||
if (!fst_read_next_text_param(endp, response, sizeof(response),
|
if (!fst_read_next_text_param(endp, response, sizeof(response),
|
||||||
@ -1483,10 +1483,10 @@ int fst_test_req_send_ack_request(const char *params)
|
|||||||
|
|
||||||
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
||||||
if (!is_valid)
|
if (!is_valid)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_group_fill_session(&g, &s))
|
if (get_group_fill_session(&g, &s))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
os_memset(&req, 0, sizeof(req));
|
os_memset(&req, 0, sizeof(req));
|
||||||
req.action = FST_ACTION_ACK_REQUEST;
|
req.action = FST_ACTION_ACK_REQUEST;
|
||||||
@ -1508,10 +1508,10 @@ int fst_test_req_send_ack_response(const char *params)
|
|||||||
|
|
||||||
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
||||||
if (!is_valid)
|
if (!is_valid)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_group_fill_session(&g, &s))
|
if (get_group_fill_session(&g, &s))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
os_memset(&res, 0, sizeof(res));
|
os_memset(&res, 0, sizeof(res));
|
||||||
res.action = FST_ACTION_ACK_RESPONSE;
|
res.action = FST_ACTION_ACK_RESPONSE;
|
||||||
@ -1533,10 +1533,10 @@ int fst_test_req_send_tear_down(const char *params)
|
|||||||
|
|
||||||
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
fsts_id = fst_read_next_int_param(params, &is_valid, &endp);
|
||||||
if (!is_valid)
|
if (!is_valid)
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (get_group_fill_session(&g, &s))
|
if (get_group_fill_session(&g, &s))
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
os_memset(&td, 0, sizeof(td));
|
os_memset(&td, 0, sizeof(td));
|
||||||
td.action = FST_ACTION_TEAR_DOWN;
|
td.action = FST_ACTION_TEAR_DOWN;
|
||||||
|
Loading…
Reference in New Issue
Block a user