Skip to content
Snippets Groups Projects
Commit 987a725b authored by Adam Wujek's avatar Adam Wujek
Browse files

lib/cmdline: don't crash if value for a parameter is missing


Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent f97eb04d
No related branches found
No related tags found
No related merge requests found
......@@ -72,22 +72,36 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
switch (a[1]) {
case 'd':
/* Use the general flags, per-instance TBD */
a = argv[++i];
if (!(a = argv[++i])) {
err = 1;
break;
}
pp_global_d_flags = pp_diag_parse(a);
break;
case 'C':
if (pp_config_string(ppg, argv[++i]) != 0)
if (!(a = argv[++i])) {
err = 1;
break;
}
if (pp_config_string(ppg, a) != 0)
return -1;
break;
case 'f':
if (pp_config_file(ppg, 1, argv[++i]) != 0)
if (!(a = argv[++i])) {
err = 1;
break;
}
if (pp_config_file(ppg, 1, a) != 0)
return -1;
break;
case 't':
GOPTS(ppg)->flags |= PP_FLAG_NO_ADJUST;
break;
case 'w':
a = argv[++i];
if (!(a = argv[++i])) {
err = 1;
break;
}
GOPTS(ppg)->s = atoi(a);
break;
case 'h':
......@@ -96,6 +110,11 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case 'G':
/* gptp_mode not supported: fall through */
default:
err = 1;
break;
}
if (err) {
pp_printf("Wrong parameter!\n\n");
cmd_line_print_help();
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment