Fix error checking for --inject-secrets argument.

If there was no secrets type specified, say so.  Otherwise, if the
secrets type wasn't valid, report the correct string as the invalid
secrets type.

Change-Id: I3cd7d419ce3577fc176a256069456c5b49e81608
Reviewed-on: https://code.wireshark.org/review/31667
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-01-21 20:57:13 -08:00
parent 079fbb8b82
commit d3eb10c2c1
1 changed files with 9 additions and 5 deletions

View File

@ -1102,13 +1102,17 @@ main(int argc, char *argv[])
goto clean_exit;
}
gchar **splitted = g_strsplit(optarg, ",", 2);
if (splitted[0]) {
if (splitted[0] && splitted[0][0] != '\0') {
secrets_type_id = lookup_secrets_type(splitted[0]);
if (secrets_type_id == 0) {
fprintf(stderr, "editcap: \"%s\" isn't a valid secrets type\n", splitted[0]);
g_strfreev(splitted);
ret = INVALID_OPTION;
goto clean_exit;
}
secrets_filename = splitted[1];
}
if (secrets_type_id == 0) {
fprintf(stderr, "editcap: \"%s\" isn't a valid secrets type\n", secrets_filename);
} else {
fprintf(stderr, "editcap: no secrets type was specified for --inject-secrets\n");
g_strfreev(splitted);
ret = INVALID_OPTION;
goto clean_exit;