diff --git a/src/main.c b/src/main.c index 40858fc..24accca 100644 --- a/src/main.c +++ b/src/main.c @@ -63,8 +63,10 @@ int main(int ac, char **av) return 1; } - if (get_interface_name(&general.host) < 0) + if (get_interface_name(&general.host) < 0) { + free_options(options); return -1; + } char *nb_threads_str = get_option_arg(options, FL_SPEEDUP); uint8_t nb_threads = 0; diff --git a/src/parsing.c b/src/parsing.c index 6643236..7d621b1 100644 --- a/src/parsing.c +++ b/src/parsing.c @@ -229,10 +229,11 @@ struct option_lst *parse_options(int ac, char *const *av) default: break; } - if (check_arg(option_index, optarg) < 0) - return NULL; - if (add_option(&head, option_index, optarg) < 0) + if (check_arg(option_index, optarg) < 0 || add_option(&head, option_index, optarg) < 0) + { + free_options(head); return NULL; + } } return head; } @@ -259,12 +260,5 @@ int parsing(struct scan *general, const struct option_lst *options) general->max_retries = max_retries ? atoi(max_retries) : 1; const char *ttl = get_option_arg(options, FL_TTL); general->ttl = ttl ? atoi(ttl) : 48; - const char *nb_threads_str = get_option_arg(options, FL_SPEEDUP); - uint8_t nb_threads = nb_threads_str ? atoi(nb_threads_str) : 0; - if (general->port_end - general->port_start + 1 < nb_threads) { - dprintf(2, "ft_nmap: number of threads to use must be " - "superior " - "or equals to the ports range\n"); - } return 0; }