summaryrefslogtreecommitdiffstats
path: root/src/expr/hash.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-03-07 14:49:08 +0100
committerPhil Sutter <phil@nwl.cc>2024-04-11 01:27:07 +0200
commitbe0bae0ad31b0adb506f96de083f52a2bd0d4fbf (patch)
tree378a1a3ffc541149493c184f0e3c21dfb675cebf /src/expr/hash.c
parentc48ac8cba8716a8bc4ff713ee965eee2643cfc31 (diff)
expr: Respect data_len when setting attributesHEADmaster
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 <phil@nwl.cc>
Diffstat (limited to 'src/expr/hash.c')
-rw-r--r--src/expr/hash.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/expr/hash.c b/src/expr/hash.c
index 4cd9006..eb44b2e 100644
--- a/src/expr/hash.c
+++ b/src/expr/hash.c
@@ -37,25 +37,25 @@ nftnl_expr_hash_set(struct nftnl_expr *e, uint16_t type,
struct nftnl_expr_hash *hash = nftnl_expr_data(e);
switch (type) {
case NFTNL_EXPR_HASH_SREG:
- memcpy(&hash->sreg, data, sizeof(hash->sreg));
+ memcpy(&hash->sreg, data, data_len);
break;
case NFTNL_EXPR_HASH_DREG:
- memcpy(&hash->dreg, data, sizeof(hash->dreg));
+ memcpy(&hash->dreg, data, data_len);
break;
case NFTNL_EXPR_HASH_LEN:
- memcpy(&hash->len, data, sizeof(hash->len));
+ memcpy(&hash->len, data, data_len);
break;
case NFTNL_EXPR_HASH_MODULUS:
- memcpy(&hash->modulus, data, sizeof(hash->modulus));
+ memcpy(&hash->modulus, data, data_len);
break;
case NFTNL_EXPR_HASH_SEED:
- memcpy(&hash->seed, data, sizeof(hash->seed));
+ memcpy(&hash->seed, data, data_len);
break;
case NFTNL_EXPR_HASH_OFFSET:
- memcpy(&hash->offset, data, sizeof(hash->offset));
+ memcpy(&hash->offset, data, data_len);
break;
case NFTNL_EXPR_HASH_TYPE:
- memcpy(&hash->type, data, sizeof(hash->type));
+ memcpy(&hash->type, data, data_len);
break;
default:
return -1;