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 <[email protected]>
---
 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

Reply via email to