editcap: give error when using `-r` and no packets

If the user calls `editcap -r` without specifying ranges of packets to
keep, abort with an error message.
This commit is contained in:
David Perry 2023-03-21 13:20:32 -04:00 committed by AndersBroman
parent 49b323219c
commit 8b7e9e4b96
1 changed files with 6 additions and 0 deletions

View File

@ -1829,6 +1829,12 @@ main(int argc, char *argv[])
if (add_selection(argv[i], &max_packet_number) == FALSE)
break;
if (keep_em && max_selected == 0) {
fprintf(stderr, "editcap: must specify packets to keep when using -r\n");
ret = WS_EXIT_INVALID_OPTION;
goto clean_exit;
}
if (!keep_em)
max_packet_number = G_MAXUINT;