summaryrefslogtreecommitdiffstats
path: root/src/expr/queue.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-03-09 11:14:29 +0100
committerPhil Sutter <phil@nwl.cc>2021-03-15 12:22:56 +0100
commit5819e46b47c331be01c2f417085c516f3f0aded3 (patch)
treecf01f0d7b493d89a13321d706fa18762a3a49ea3 /src/expr/queue.c
parent228e8b1746270ee5c4a41b671a01369c75622587 (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/queue.c')
-rw-r--r--src/expr/queue.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/expr/queue.c b/src/expr/queue.c
index 051ef71..b892b57 100644
--- a/src/expr/queue.c
+++ b/src/expr/queue.c
@@ -153,31 +153,31 @@ static int nftnl_expr_queue_snprintf_default(char *buf, size_t len,
if (e->flags & (1 << NFTNL_EXPR_QUEUE_NUM)) {
total_queues = queue->queuenum + queue->queues_total - 1;
- ret = snprintf(buf + offset, len, "num %u", queue->queuenum);
+ ret = snprintf(buf + offset, remain, "num %u", queue->queuenum);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
if (queue->queues_total && total_queues != queue->queuenum) {
- ret = snprintf(buf + offset, len, "-%u", total_queues);
+ ret = snprintf(buf + offset, remain, "-%u", total_queues);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
- ret = snprintf(buf + offset, len, " ");
+ ret = snprintf(buf + offset, remain, " ");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
if (e->flags & (1 << NFTNL_EXPR_QUEUE_SREG_QNUM)) {
- ret = snprintf(buf + offset, len, "sreg_qnum %u ",
+ ret = snprintf(buf + offset, remain, "sreg_qnum %u ",
queue->sreg_qnum);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
if (e->flags & (1 << NFTNL_EXPR_QUEUE_FLAGS)) {
if (queue->flags & (NFT_QUEUE_FLAG_BYPASS)) {
- ret = snprintf(buf + offset, len, "bypass ");
+ ret = snprintf(buf + offset, remain, "bypass ");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
if (queue->flags & (NFT_QUEUE_FLAG_CPU_FANOUT)) {
- ret = snprintf(buf + offset, len, "fanout ");
+ ret = snprintf(buf + offset, remain, "fanout ");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
}