From be0bae0ad31b0adb506f96de083f52a2bd0d4fbf Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 7 Mar 2024 14:49:08 +0100 Subject: expr: Respect data_len when setting attributes With attr_policy in place, data_len has an upper boundary but it may be lower than the attribute's storage area in which case memcpy() would read garbage. Signed-off-by: Phil Sutter --- src/expr/osf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/expr/osf.c') diff --git a/src/expr/osf.c b/src/expr/osf.c index 1e4ceb0..060394b 100644 --- a/src/expr/osf.c +++ b/src/expr/osf.c @@ -25,13 +25,13 @@ static int nftnl_expr_osf_set(struct nftnl_expr *e, uint16_t type, switch(type) { case NFTNL_EXPR_OSF_DREG: - memcpy(&osf->dreg, data, sizeof(osf->dreg)); + memcpy(&osf->dreg, data, data_len); break; case NFTNL_EXPR_OSF_TTL: - memcpy(&osf->ttl, data, sizeof(osf->ttl)); + memcpy(&osf->ttl, data, data_len); break; case NFTNL_EXPR_OSF_FLAGS: - memcpy(&osf->flags, data, sizeof(osf->flags)); + memcpy(&osf->flags, data, data_len); break; } return 0; -- cgit v1.2.3