From 94de79153f1d14ba0385037202fd0e5e5a6f7b5b Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sat, 8 Jun 2024 20:42:13 +0200 Subject: [PATCH] Fix incorrect return-value check for a scanf like function --- src/fping.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fping.c b/src/fping.c index cd8f561..e44f8d8 100644 --- a/src/fping.c +++ b/src/fping.c @@ -621,7 +621,7 @@ int main(int argc, char **argv) break; case 't': - if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) + if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1) usage(1); if (opt_value_float < 0) { usage(1); @@ -631,12 +631,12 @@ int main(int argc, char **argv) break; case 'r': - if (!sscanf(optparse_state.optarg, "%u", &retry)) + if (sscanf(optparse_state.optarg, "%u", &retry) != 1) usage(1); break; case 'i': - if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) + if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1) usage(1); if (opt_value_float < 0) { usage(1); @@ -645,7 +645,7 @@ int main(int argc, char **argv) break; case 'p': - if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) + if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1) usage(1); if (opt_value_float < 0) { usage(1); @@ -670,7 +670,7 @@ int main(int argc, char **argv) break; case 'b': - if (!sscanf(optparse_state.optarg, "%u", &ping_data_size)) + if (sscanf(optparse_state.optarg, "%u", &ping_data_size) != 1) usage(1); break; @@ -687,7 +687,7 @@ int main(int argc, char **argv) case 'Q': verbose_flag = 0; quiet_flag = 1; - if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) + if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1) usage(1); if (opt_value_float < 0) { usage(1); @@ -865,7 +865,7 @@ int main(int argc, char **argv) break; case 'O': - if (sscanf(optparse_state.optarg, "%i", &tos)) { + if (sscanf(optparse_state.optarg, "%i", &tos) == 1) { if (socket4 >= 0) { if (setsockopt(socket4, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) { perror("setting type of service octet IP_TOS");