From 6830ddad67e245b7aed7ef0c3dfcf775d68a4841 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 19 Dec 2024 08:44:00 +0200 Subject: [PATCH 1/2] tncattach - WHen parsing the `prefixPart_s` (the prefix length), only continue if the text is a number, if not then bail out with an error --- tncattach.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tncattach.c b/tncattach.c index ab5772c..04041eb 100644 --- a/tncattach.c +++ b/tncattach.c @@ -504,6 +504,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { long prefixLen_l = strtol(prefixPart_s, NULL, 10); // TODO: Add handling here for errors (using errno) + if(prefixLen_l == 0) { + printf("Prefix length '%s' is not numeric\n", prefixPart_s); + exit(EXIT_FAILURE); + } arguments->ipv6 = ipPart_s; From c4c748a46516f34de7c94774388a4ffbbf7421da Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 19 Dec 2024 08:45:44 +0200 Subject: [PATCH 2/2] tncattach - Only allow prefix length of between 0 to 128 --- tncattach.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tncattach.c b/tncattach.c index 04041eb..802ff74 100644 --- a/tncattach.c +++ b/tncattach.c @@ -508,6 +508,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { printf("Prefix length '%s' is not numeric\n", prefixPart_s); exit(EXIT_FAILURE); } + else if(!(prefixLen_l >= 0 && prefixLen_l <= 128)) + { + printf("Prefix length '%s' is not within valid range of 0-128\n", prefixPart_s); + exit(EXIT_FAILURE); + } arguments->ipv6 = ipPart_s;