Skip to content

Commit

Permalink
xfrm: return -NLE_MISSING_ATTR from xfrmnl_sa_get_auth_params()
Browse files Browse the repository at this point in the history
Don't return -1, that is not an error code.

Also, return early from function.
  • Loading branch information
thom311 committed Dec 4, 2023
1 parent d8a1ff3 commit daa8efc
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lib/xfrm/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,20 +1826,17 @@ int xfrmnl_sa_set_aead_params (struct xfrmnl_sa* sa, const char* alg_name, unsig
*/
int xfrmnl_sa_get_auth_params (struct xfrmnl_sa* sa, char* alg_name, unsigned int* key_len, unsigned int* trunc_len, char* key)
{
if (sa->ce_mask & XFRM_SA_ATTR_ALG_AUTH)
{
if (alg_name)
strcpy (alg_name, sa->auth->alg_name);
if (key_len)
*key_len = sa->auth->alg_key_len;
if (trunc_len)
*trunc_len = sa->auth->alg_trunc_len;
if (key)
memcpy (key, sa->auth->alg_key, (sa->auth->alg_key_len + 7)/8);
}
else
return -1;
if (!(sa->ce_mask & XFRM_SA_ATTR_ALG_AUTH))
return -NLE_MISSING_ATTR;

if (alg_name)
strcpy(alg_name, sa->auth->alg_name);
if (key_len)
*key_len = sa->auth->alg_key_len;
if (trunc_len)
*trunc_len = sa->auth->alg_trunc_len;
if (key)
memcpy(key, sa->auth->alg_key, (sa->auth->alg_key_len + 7) / 8);
return 0;
}

Expand Down

0 comments on commit daa8efc

Please sign in to comment.