diff options
author | Phil Sutter <phil@nwl.cc> | 2021-03-09 11:14:29 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-03-15 12:22:56 +0100 |
commit | 5819e46b47c331be01c2f417085c516f3f0aded3 (patch) | |
tree | cf01f0d7b493d89a13321d706fa18762a3a49ea3 /src/expr/redir.c | |
parent | 228e8b1746270ee5c4a41b671a01369c75622587 (diff) |
expr: Fix snprintf buffer length updates
Subsequent calls to snprintf() sometimes reuse 'len' variable although
they should refer to the updated value in 'remain' instead.
Fixes: 676ea569bbe5a ("src: Change parameters of SNPRINTF_BUFFER_SIZE macro.")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/expr/redir.c')
-rw-r--r-- | src/expr/redir.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/expr/redir.c b/src/expr/redir.c index 477659a..c00c2a6 100644 --- a/src/expr/redir.c +++ b/src/expr/redir.c @@ -138,19 +138,19 @@ static int nftnl_expr_redir_snprintf_default(char *buf, size_t len, struct nftnl_expr_redir *redir = nftnl_expr_data(e); if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN)) { - ret = snprintf(buf + offset, len, "proto_min reg %u ", + ret = snprintf(buf + offset, remain, "proto_min reg %u ", redir->sreg_proto_min); SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MAX)) { - ret = snprintf(buf + offset, len, "proto_max reg %u ", + ret = snprintf(buf + offset, remain, "proto_max reg %u ", redir->sreg_proto_max); SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_FLAGS)) { - ret = snprintf(buf + offset, len, "flags 0x%x ", + ret = snprintf(buf + offset, remain, "flags 0x%x ", redir->flags); SNPRINTF_BUFFER_SIZE(ret, remain, offset); } |