summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-03-09 12:16:12 +0100
committerPhil Sutter <phil@nwl.cc>2021-03-15 12:23:04 +0100
commitf072e2e68b460acdb4b6370f552a7c5a48ddd66f (patch)
treea509fd4192d171311880366c4734f045d80a3a40 /src
parent1f55b4794ad797503d80f51af4adb467206924ed (diff)
obj/ct_timeout: Fix snprintf buffer length updates
Have to pass shrinking 'remain' variable to consecutive snprintf calls instead of the unchanged 'len' parameter. Fixes: 0adceeab1597a ("src: add ct timeout support") Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src')
-rw-r--r--src/obj/ct_timeout.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/obj/ct_timeout.c b/src/obj/ct_timeout.c
index 2662cac..c3f577b 100644
--- a/src/obj/ct_timeout.c
+++ b/src/obj/ct_timeout.c
@@ -266,12 +266,12 @@ static int nftnl_obj_ct_timeout_snprintf_default(char *buf, size_t len,
struct nftnl_obj_ct_timeout *timeout = nftnl_obj_data(e);
if (e->flags & (1 << NFTNL_OBJ_CT_TIMEOUT_L3PROTO)) {
- ret = snprintf(buf + offset, len, "family %d ",
+ ret = snprintf(buf + offset, remain, "family %d ",
timeout->l3proto);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
if (e->flags & (1 << NFTNL_OBJ_CT_TIMEOUT_L4PROTO)) {
- ret = snprintf(buf + offset, len, "protocol %d ",
+ ret = snprintf(buf + offset, remain, "protocol %d ",
timeout->l4proto);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
@@ -283,7 +283,7 @@ static int nftnl_obj_ct_timeout_snprintf_default(char *buf, size_t len,
if (timeout_protocol[timeout->l4proto].attr_max == 0)
l4num = IPPROTO_RAW;
- ret = snprintf(buf + offset, len, "policy = {");
+ ret = snprintf(buf + offset, remain, "policy = {");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
for (i = 0; i < timeout_protocol[l4num].attr_max; i++) {
@@ -293,13 +293,13 @@ static int nftnl_obj_ct_timeout_snprintf_default(char *buf, size_t len,
"UNKNOWN";
if (timeout->timeout[i] != timeout_protocol[l4num].dflt_timeout[i]) {
- ret = snprintf(buf + offset, len,
+ ret = snprintf(buf + offset, remain,
"%s = %u,", state_name, timeout->timeout[i]);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
}
- ret = snprintf(buf + offset, len, "}");
+ ret = snprintf(buf + offset, remain, "}");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
buf[offset] = '\0';