From e11b4bd01c64688bdf3714470f81a7e9fddd09aa Mon Sep 17 00:00:00 2001 From: Daniele Forsi IU5HKX Date: Mon, 10 Apr 2023 09:15:12 +0200 Subject: [PATCH] Fix segfaults with malformed input and wrong command line arguments Fixes: NULL dereference. Steps to reproduce: echo L | tests/ampctl echo L | tests/rigctl echo L | tests/rotctl --- tests/ampctl_parse.c | 2 +- tests/rigctl_parse.c | 2 +- tests/rotctl_parse.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 55d2137ad..b7256e122 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -1100,7 +1100,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) rp_getline(pmptstr); - if (!(strcmp(input_line, ""))) + if (!input_line || !(strcmp(input_line, ""))) { fprintf(fout, "? for help, q to quit.\n"); fflush(fout); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 97e9ccd6b..c87ce2ae5 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1478,7 +1478,7 @@ readline_repeat: rp_getline(pmptstr); - if (!(strcmp(input_line, ""))) + if (!input_line || !(strcmp(input_line, ""))) { fprintf(fout, "? for help, q to quit.\n"); fflush(fout); diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 1de1bda95..263460a94 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1160,7 +1160,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, rp_getline(pmptstr); - if (!(strcmp(input_line, ""))) + if (!input_line || !(strcmp(input_line, ""))) { fprintf(fout, "? for help, q to quit.\n"); fflush(fout);