From b34e3435c21d06b3e5a4e7b5246fb6ddb6641a9f Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 1 Oct 2018 02:32:51 +0200 Subject: tools: Remove length check on device UDID arguments to support newer devices The 40 characters length check on the device UDID made newer devices unusable with the libimobiledevice tools and was actually redundant since an invalid UDID will always fail to resolve. This commit removes the length check alltogether (but makes sure it is not an empty string ""). --- tools/ideviceimagemounter.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'tools/ideviceimagemounter.c') diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index d56fa0c..7101c7e 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c @@ -63,7 +63,7 @@ static void print_usage(int argc, char **argv) name = strrchr(argv[0], '/'); printf("Usage: %s [OPTIONS] IMAGE_FILE IMAGE_SIGNATURE_FILE\n\n", (name ? name + 1: argv[0])); printf("Mounts the specified disk image on the device.\n\n"); - printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); + printf(" -u, --udid UDID\ttarget specific device by UDID\n"); printf(" -l, --list\t\tList mount information\n"); printf(" -t, --imagetype\tImage type to use, default is 'Developer'\n"); printf(" -x, --xml\t\tUse XML output\n"); @@ -76,19 +76,18 @@ static void print_usage(int argc, char **argv) static void parse_opts(int argc, char **argv) { static struct option longopts[] = { - {"help", 0, NULL, 'h'}, - {"udid", 0, NULL, 'u'}, - {"list", 0, NULL, 'l'}, - {"imagetype", 0, NULL, 't'}, - {"xml", 0, NULL, 'x'}, - {"debug", 0, NULL, 'd'}, + {"help", no_argument, NULL, 'h'}, + {"udid", required_argument, NULL, 'u'}, + {"list", no_argument, NULL, 'l'}, + {"imagetype", required_argument, NULL, 't'}, + {"xml", no_argument, NULL, 'x'}, + {"debug", no_argument, NULL, 'd'}, {NULL, 0, NULL, 0} }; int c; while (1) { - c = getopt_long(argc, argv, "hu:lt:xd", longopts, - (int *) 0); + c = getopt_long(argc, argv, "hu:lt:xd", longopts, NULL); if (c == -1) { break; } @@ -98,14 +97,12 @@ static void parse_opts(int argc, char **argv) print_usage(argc, argv); exit(0); case 'u': - if (strlen(optarg) != 40) { - printf("%s: invalid UDID specified (length != 40)\n", - argv[0]); + if (!*optarg) { + fprintf(stderr, "ERROR: UDID must not be empty!\n"); print_usage(argc, argv); exit(2); } - if (udid) - free(udid); + free(udid); udid = strdup(optarg); break; case 'l': -- cgit v1.1-32-gdbae