summaryrefslogtreecommitdiff
path: root/src/tools/oping
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2022-03-29 19:38:44 +0200
committerSander Vrijders <[email protected]>2022-03-30 15:12:25 +0200
commitc219668c4d2459579af77f6a2fb782337ca0fbae (patch)
tree265f5aae3d936e56cf489d90ababd66c3ab0250a /src/tools/oping
parent64cbe652a72ac81a3d5efc4bb01d25dd52166137 (diff)
downloadouroboros-c219668c4d2459579af77f6a2fb782337ca0fbae.tar.gz
ouroboros-c219668c4d2459579af77f6a2fb782337ca0fbae.zip
tools: Fix SEGV in oping with missing param values
If not passed a value for the last parameter, oping would SEGV. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/tools/oping')
-rw-r--r--src/tools/oping/oping.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 62eb94d5..e215b217 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -175,30 +175,36 @@ int main(int argc,
server.quiet = false;
while (argc > 0) {
- if (strcmp(*argv, "-i") == 0 ||
- strcmp(*argv, "--interval") == 0) {
+ if ((strcmp(*argv, "-i") == 0 ||
+ strcmp(*argv, "--interval") == 0) &&
+ argc > 1) {
client.interval = strtol(*(++argv), &rem, 10);
client.interval *= time_mul(rem);
--argc;
- } else if (strcmp(*argv, "-n") == 0 ||
- strcmp(*argv, "--server-name") == 0) {
+ } else if ((strcmp(*argv, "-n") == 0 ||
+ strcmp(*argv, "--server-name") == 0) &&
+ argc > 1) {
client.s_apn = *(++argv);
--argc;
- } else if (strcmp(*argv, "-c") == 0 ||
- strcmp(*argv, "--count") == 0) {
+ } else if ((strcmp(*argv, "-c") == 0 ||
+ strcmp(*argv, "--count") == 0) &&
+ argc > 1) {
client.count = strtol(*(++argv), &rem, 10);
--argc;
- } else if (strcmp(*argv, "-d") == 0 ||
- strcmp(*argv, "--duration") == 0) {
+ } else if ((strcmp(*argv, "-d") == 0 ||
+ strcmp(*argv, "--duration") == 0) &&
+ argc > 1) {
duration = strtol(*(++argv), &rem, 10);
duration *= time_mul(rem);
--argc;
- } else if (strcmp(*argv, "-s") == 0 ||
- strcmp(*argv, "--size") == 0) {
+ } else if ((strcmp(*argv, "-s") == 0 ||
+ strcmp(*argv, "--size") == 0) &&
+ argc > 1) {
client.size = strtol(*(++argv), &rem, 10);
--argc;
- } else if (strcmp(*argv, "-q") == 0 ||
- strcmp(*argv, "--qos") == 0) {
+ } else if ((strcmp(*argv, "-q") == 0 ||
+ strcmp(*argv, "--qos") == 0) &&
+ argc > 1) {
qos = *(++argv);
--argc;
} else if (strcmp(*argv, "-l") == 0 ||