From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 2/5] batctl: debug: use strict interval/timeout parsing
Date: Sat, 04 Jul 2026 21:36:00 +0200 [thread overview]
Message-ID: <20260704-bugfixes-debug-v1-2-888ddc878206@narfation.org> (raw)
In-Reply-To: <20260704-bugfixes-debug-v1-0-888ddc878206@narfation.org>
The sscanf() function does not only return 0 when the value could not be
parsed from the string. Also EOF is a potential return value. To make the
check more strict, just compare the returned value with the expected number
of scanned/parsed items.
Fixes: 302a41a73915 ("batctl: Add timeout filtering option for originators")
Fixes: e4a7b7733faf ("batctl: Add an optional interval for watch-mode")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/debug.c b/debug.c
index bca81c8..ae13dce 100644
--- a/debug.c
+++ b/debug.c
@@ -67,7 +67,7 @@ int handle_debug_table(struct state *state, int argc, char **argv)
if (!optarg)
break;
- if (!sscanf(optarg, "%f", &watch_interval)) {
+ if (sscanf(optarg, "%f", &watch_interval) != 1) {
fprintf(stderr,
"Error - provided argument of '-%c' is not a number\n",
optchar);
@@ -82,7 +82,7 @@ int handle_debug_table(struct state *state, int argc, char **argv)
}
read_opt |= NO_OLD_ORIGS;
- if (!sscanf(optarg, "%f", &orig_timeout)) {
+ if (sscanf(optarg, "%f", &orig_timeout) != 1) {
fprintf(stderr,
"Error - provided argument of '-%c' is not a number\n",
optchar);
--
2.47.3
next prev parent reply other threads:[~2026-07-04 19:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 19:35 [PATCH 0/5] batctl: debug tables bugfixes Sven Eckelmann
2026-07-04 19:35 ` [PATCH 1/5] batctl: debug: avoid endless getopt loop for attached '-w' argument Sven Eckelmann
2026-07-04 19:36 ` Sven Eckelmann [this message]
2026-07-04 19:36 ` [PATCH 3/5] batctl: debug: reject trailing garbage for intervals Sven Eckelmann
2026-07-04 19:36 ` [PATCH 4/5] batctl: debug: reject non-finite/negative interval/timeout values Sven Eckelmann
2026-07-04 19:36 ` [PATCH 5/5] batctl: debug: don't return negative error codes from handle_debug_table Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260704-bugfixes-debug-v1-2-888ddc878206@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.