Compare commits

...

2 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire
c4c748a465 tncattach
- Only allow prefix length of between 0 to 128
2024-12-19 08:45:44 +02:00
Tristan B. Velloza Kildaire
6830ddad67 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
2024-12-19 08:44:00 +02:00

View File

@ -504,6 +504,15 @@ 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) 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);
}
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; arguments->ipv6 = ipPart_s;