diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-02-11 00:00:06 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-02-11 01:46:31 +0100 |
commit | de18ddf49a27a98b1b5b999a80946b10ea3e0843 (patch) | |
tree | 88a0e73fe70d54b938c4ec34968ea74818106848 /tools | |
parent | e5a5176e2af204d154008f871ff577b50186ab8d (diff) | |
download | hardware_replicant_libsamsung-ipc-de18ddf49a27a98b1b5b999a80946b10ea3e0843.tar.gz hardware_replicant_libsamsung-ipc-de18ddf49a27a98b1b5b999a80946b10ea3e0843.tar.bz2 hardware_replicant_libsamsung-ipc-de18ddf49a27a98b1b5b999a80946b10ea3e0843.zip |
tools: nv_data-imei: fix crash with commands options without command
Without that fix command can be NULL when it reaches this assert:
assert(command->options & OPTION_FILE);
The crash can be reproduced by running nv_data-imei with command
options but without the command itself, for example with
'nv_data-imei -i 1'.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nv_data-imei.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/nv_data-imei.c b/tools/nv_data-imei.c index 766c7a8..64ce3f5 100644 --- a/tools/nv_data-imei.c +++ b/tools/nv_data-imei.c @@ -1021,11 +1021,12 @@ int main(int argc, char * const argv[]) /* We use the - in optstring so all arguments go in the 'case 1:' */ assert(optind == argc); - if (argc == 2) { + if (argc == 2 || command == NULL) { /* If none of the commands or options were reached, we are in - * the case where users ran 'nv_data-imei FILE'. + * the case where users ran 'nv_data-imei FILE' or used some + * options like -i <argument> without any command. */ - printf("Missing options, commands or invalid command '%s'\n", + printf("Missing options, command or invalid command '%s'\n", argv[1]); printf("Try -h to print the help.\n"); return EX_USAGE; |