Skip to content

Commit

Permalink
xfrm: fix parsing address in xfrmnl_ae_parse()
Browse files Browse the repository at this point in the history
Passing a size of (sizeof (ae_id->saddr)) is wrong for IPv4. The size depends
on the address family.

Fixes: 9171544 ('xfrm: add xfrm support')
  • Loading branch information
thom311 committed Nov 29, 2023
1 parent 8b6dc83 commit 9c97def
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/xfrm/ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
#include "nl-priv-dynamic-core/object-api.h"
#include "nl-priv-dynamic-core/nl-core.h"
#include "nl-priv-dynamic-core/cache-api.h"
#include "nl-aux-core/nl-core.h"

/** @cond SKIP */

Expand Down Expand Up @@ -540,11 +541,11 @@ int xfrmnl_ae_parse(struct nlmsghdr *n, struct xfrmnl_ae **result)
if (err < 0)
goto errout;

ae->sa_id.daddr = nl_addr_build(ae_id->sa_id.family, &ae_id->sa_id.daddr, sizeof (ae_id->sa_id.daddr));
ae->sa_id.daddr = _nl_addr_build(ae_id->sa_id.family, &ae_id->sa_id.daddr);
ae->sa_id.family= ae_id->sa_id.family;
ae->sa_id.spi = ntohl(ae_id->sa_id.spi);
ae->sa_id.proto = ae_id->sa_id.proto;
ae->saddr = nl_addr_build(ae_id->sa_id.family, &ae_id->saddr, sizeof (ae_id->saddr));
ae->saddr = _nl_addr_build(ae_id->sa_id.family, &ae_id->saddr);
ae->reqid = ae_id->reqid;
ae->flags = ae_id->flags;
ae->ce_mask |= (XFRM_AE_ATTR_DADDR | XFRM_AE_ATTR_FAMILY | XFRM_AE_ATTR_SPI |
Expand Down

0 comments on commit 9c97def

Please sign in to comment.