diff options
35 files changed, 95 insertions, 97 deletions
diff --git a/common/userpref.c b/common/userpref.c index 0fa5b96..b985285 100644 --- a/common/userpref.c +++ b/common/userpref.c @@ -208,14 +208,8 @@ int userpref_read_system_buid(char **system_buid) */ userpref_error_t userpref_get_paired_udids(char ***list, unsigned int *count) { - struct slist_t { - char *name; - void *next; - }; DIR *config_dir; const char *config_path = NULL; - struct slist_t *udids = NULL; - unsigned int i; unsigned int found = 0; if (!list || (list && *list)) { @@ -226,41 +220,42 @@ userpref_error_t userpref_get_paired_udids(char ***list, unsigned int *count) if (count) { *count = 0; } + *list = (char**)malloc(sizeof(char*)); config_path = userpref_get_config_dir(); config_dir = opendir(config_path); if (config_dir) { struct dirent *entry; - struct slist_t *listp = udids; while ((entry = readdir(config_dir))) { - char *ext = strstr(entry->d_name, USERPREF_CONFIG_EXTENSION); - if (ext && ((ext - entry->d_name) == 40) && (strlen(entry->d_name) == (40 + strlen(ext)))) { - struct slist_t *ne = (struct slist_t*)malloc(sizeof(struct slist_t)); - ne->name = (char*)malloc(41); - strncpy(ne->name, entry->d_name, 40); - ne->name[40] = 0; - ne->next = NULL; - if (!listp) { - listp = ne; - udids = listp; - } else { - listp->next = ne; - listp = listp->next; + if (strcmp(entry->d_name, USERPREF_CONFIG_FILE) == 0) { + /* ignore SystemConfiguration.plist */ + continue; + } + char *ext = strrchr(entry->d_name, '.'); + if (ext && (strcmp(ext, USERPREF_CONFIG_EXTENSION) == 0)) { + size_t len = strlen(entry->d_name) - strlen(USERPREF_CONFIG_EXTENSION); + char **newlist = (char**)realloc(*list, sizeof(char*) * (found+2)); + if (!newlist) { + fprintf(stderr, "ERROR: Out of memory\n"); + break; + } + *list = newlist; + char *tmp = (char*)malloc(len+1); + if (tmp) { + strncpy(tmp, entry->d_name, len); + tmp[len] = '\0'; + } + (*list)[found] = tmp; + if (!tmp) { + fprintf(stderr, "ERROR: Out of memory\n"); + break; } found++; } } closedir(config_dir); } - *list = (char**)malloc(sizeof(char*) * (found+1)); - i = 0; - while (udids) { - (*list)[i++] = udids->name; - struct slist_t *old = udids; - udids = udids->next; - free(old); - } - (*list)[i] = NULL; + (*list)[found] = NULL; if (count) { *count = found; diff --git a/docs/idevice_id.1 b/docs/idevice_id.1 index cdc5342..e223dcb 100644 --- a/docs/idevice_id.1 +++ b/docs/idevice_id.1 @@ -8,7 +8,7 @@ idevice_id \- Prints device name or a list of attached devices. .SH DESCRIPTION Prints device name or a list of attached devices. -The UDID is a 40-digit hexadecimal number of the device +UDID is the unique device identifier of the device for which the name should be retrieved. .SH OPTIONS diff --git a/docs/idevicebackup.1 b/docs/idevicebackup.1 index a9330e0..517ca2a 100644 --- a/docs/idevicebackup.1 +++ b/docs/idevicebackup.1 @@ -12,7 +12,7 @@ Create or restore backup from the current or specified directory. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/idevicebackup2.1 b/docs/idevicebackup2.1 index 1b50a2b..6c40929 100644 --- a/docs/idevicebackup2.1 +++ b/docs/idevicebackup2.1 @@ -12,7 +12,7 @@ Create or restore backup from the current or specified directory. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-s, \-\-source UDID use backup data from device specified by UDID. diff --git a/docs/idevicecrashreport.1 b/docs/idevicecrashreport.1 index 24015d3..a3742e7 100644 --- a/docs/idevicecrashreport.1 +++ b/docs/idevicecrashreport.1 @@ -25,7 +25,7 @@ copy but do not remove crash reports from device. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-h, \-\-help prints usage information. diff --git a/docs/idevicedate.1 b/docs/idevicedate.1 index aa77df6..adb091a 100644 --- a/docs/idevicedate.1 +++ b/docs/idevicedate.1 @@ -15,7 +15,7 @@ Simple utility to manage the clock on a device. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-s, \-\-set TIMESTAMP set UTC time described by TIMESTAMP diff --git a/docs/idevicedebug.1 b/docs/idevicedebug.1 index daa3c0c..2024842 100644 --- a/docs/idevicedebug.1 +++ b/docs/idevicedebug.1 @@ -17,7 +17,7 @@ stdout/stderr of the process. set environment variable NAME to VALUE. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/idevicedebugserverproxy.1 b/docs/idevicedebugserverproxy.1 index 669806a..e2372e6 100644 --- a/docs/idevicedebugserverproxy.1 +++ b/docs/idevicedebugserverproxy.1 @@ -17,7 +17,7 @@ The developer disk image needs to be mounted for this service to be available. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/idevicediagnostics.1 b/docs/idevicediagnostics.1 index 460c17f..8a9b947 100644 --- a/docs/idevicediagnostics.1 +++ b/docs/idevicediagnostics.1 @@ -16,7 +16,7 @@ iOS 5 and later. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/ideviceenterrecovery.1 b/docs/ideviceenterrecovery.1 index feea733..cbceb36 100644 --- a/docs/ideviceenterrecovery.1 +++ b/docs/ideviceenterrecovery.1 @@ -7,7 +7,7 @@ ideviceenterrecovery \- Make a device enter recovery mode. .SH DESCRIPTION -Makes a device with the supplied 40-digit UDID enter recovery mode immediately. +Makes a device with the supplied UDID enter recovery mode immediately. .SH OPTIONS .TP diff --git a/docs/ideviceimagemounter.1 b/docs/ideviceimagemounter.1 index 4afdca6..322bd34 100644 --- a/docs/ideviceimagemounter.1 +++ b/docs/ideviceimagemounter.1 @@ -15,7 +15,7 @@ Mounts the specified disk image on the device. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-l, \-\-list list mount information diff --git a/docs/ideviceinfo.1 b/docs/ideviceinfo.1 index f61c713..d4ecbf0 100644 --- a/docs/ideviceinfo.1 +++ b/docs/ideviceinfo.1 @@ -15,7 +15,7 @@ Show information about the first connected device. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-q, \-\-domain NAME set domain of query to NAME. Default: None. diff --git a/docs/idevicename.1 b/docs/idevicename.1 index 67897f1..ee7cd02 100644 --- a/docs/idevicename.1 +++ b/docs/idevicename.1 @@ -21,7 +21,7 @@ is given the device name will be set to the name specified. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-h, \-\-help prints usage information diff --git a/docs/idevicenotificationproxy.1 b/docs/idevicenotificationproxy.1 index 75bf6b1..19cf02e 100644 --- a/docs/idevicenotificationproxy.1 +++ b/docs/idevicenotificationproxy.1 @@ -12,7 +12,7 @@ Post or observe notifications on an iOS device from the command line. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/idevicepair.1 b/docs/idevicepair.1 index e9916b3..5c567ee 100644 --- a/docs/idevicepair.1 +++ b/docs/idevicepair.1 @@ -12,7 +12,7 @@ Manage host pairings with devices and usbmuxd. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-d, \-\-debug enable communication debugging. diff --git a/docs/ideviceprovision.1 b/docs/ideviceprovision.1 index b79ea82..5f312a5 100644 --- a/docs/ideviceprovision.1 +++ b/docs/ideviceprovision.1 @@ -12,7 +12,7 @@ Manage provisioning profiles on a device. .SH OPTIONS .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-x, \-\-xml print XML output when using the 'dump' command. diff --git a/docs/idevicescreenshot.1 b/docs/idevicescreenshot.1 index c2b9619..7b6794c 100644 --- a/docs/idevicescreenshot.1 +++ b/docs/idevicescreenshot.1 @@ -22,7 +22,7 @@ the screenshotr service is not available. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID. +target specific device by UDID. .TP .B \-h, \-\-help prints usage information diff --git a/docs/idevicesyslog.1 b/docs/idevicesyslog.1 index 4230461..aa24339 100644 --- a/docs/idevicesyslog.1 +++ b/docs/idevicesyslog.1 @@ -15,7 +15,7 @@ Relay syslog of a connected device. enable communication debugging. .TP .B \-u, \-\-udid UDID -target specific device by its 40-digit device UDID +target specific device by UDID. .TP .B \-h, \-\-help prints usage information. diff --git a/tools/idevice_id.c b/tools/idevice_id.c index 6f020ff..558dcbe 100644 --- a/tools/idevice_id.c +++ b/tools/idevice_id.c @@ -40,7 +40,7 @@ static void print_usage(int argc, char **argv) name = strrchr(argv[0], '/'); printf("Usage: %s [OPTIONS] [UDID]\n", (name ? name + 1: argv[0])); printf("Prints device name or a list of attached devices.\n\n"); - printf(" The UDID is a 40-digit hexadecimal number of the device\n"); + printf(" UDID is the unique device identifier of the device\n"); printf(" for which the name should be retrieved.\n\n"); printf(" -l, --list\t\tlist UDID of all attached devices\n"); printf(" -d, --debug\t\tenable communication debugging\n"); @@ -79,7 +79,7 @@ int main(int argc, char **argv) /* check if udid was passed */ if (mode == MODE_SHOW_ID) { i--; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (argc < 2 || !argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } @@ -90,7 +90,7 @@ int main(int argc, char **argv) case MODE_SHOW_ID: idevice_new(&device, udid); if (!device) { - fprintf(stderr, "ERROR: No device with UDID=%s attached.\n", udid); + fprintf(stderr, "ERROR: No device with UDID %s attached.\n", udid); return -2; } diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 7e825de..cd69bcc 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -671,7 +671,7 @@ static void print_usage(int argc, char **argv) printf(" restore\tRestores a device backup from DIRECTORY.\n\n"); printf("options:\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -715,7 +715,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 7fb67df..6d4785b 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -1323,7 +1323,7 @@ static void print_usage(int argc, char **argv) printf("\n"); printf("options:\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -s, --source UDID\tuse backup data from device specified by UDID\n"); printf(" -i, --interactive\trequest passwords interactively\n"); printf(" -h, --help\t\tprints usage information\n"); @@ -1369,7 +1369,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return -1; } @@ -1378,7 +1378,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--source")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return -1; } diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c index 4d7f41c..e05d506 100644 --- a/tools/idevicecrashreport.c +++ b/tools/idevicecrashreport.c @@ -301,7 +301,7 @@ static void print_usage(int argc, char **argv) printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n"); printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -327,7 +327,7 @@ int main(int argc, char* argv[]) { } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicedate.c b/tools/idevicedate.c index 97243bb..2676880 100644 --- a/tools/idevicedate.c +++ b/tools/idevicedate.c @@ -50,7 +50,7 @@ static void print_usage(int argc, char **argv) printf("NOTE: Setting the time on iOS 6 and later is only supported\n"); printf(" in the setup wizard screens before device activation.\n\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -s, --set TIMESTAMP\tset UTC time described by TIMESTAMP\n"); printf(" -c, --sync\t\tset time of device to current system time\n"); printf(" -h, --help\t\tprints usage information\n"); @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c index f18254a..c7508e3 100644 --- a/tools/idevicedebug.c +++ b/tools/idevicedebug.c @@ -188,7 +188,7 @@ static void print_usage(int argc, char **argv) printf("\n"); printf(" The following OPTIONS are accepted:\n"); printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\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(" -d, --debug\t\tenable communication debugging\n"); printf(" -h, --help\t\tprints usage information\n"); printf("\n"); @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); res = 0; goto cleanup; diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c index 56b1013..0b0419b 100644 --- a/tools/idevicedebugserverproxy.c +++ b/tools/idevicedebugserverproxy.c @@ -71,7 +71,7 @@ static void print_usage(int argc, char **argv) printf("Usage: %s [OPTIONS] <PORT>\n", (name ? name + 1: argv[0])); printf("Proxy debugserver connection from device to a local socket at PORT.\n\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -280,7 +280,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c index 66e192f..8c32854 100644 --- a/tools/idevicediagnostics.c +++ b/tools/idevicediagnostics.c @@ -79,7 +79,7 @@ int main(int argc, char **argv) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); result = 0; goto cleanup; @@ -318,7 +318,7 @@ void print_usage(int argc, char **argv) printf(" sleep\t\t\t\tput device into sleep mode (disconnects from host)\n\n"); printf(" The following OPTIONS are accepted:\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); diff --git a/tools/ideviceenterrecovery.c b/tools/ideviceenterrecovery.c index 21c4ff6..69484cc 100644 --- a/tools/ideviceenterrecovery.c +++ b/tools/ideviceenterrecovery.c @@ -37,7 +37,7 @@ static void print_usage(int argc, char **argv) name = strrchr(argv[0], '/'); printf("Usage: %s [OPTIONS] UDID\n", (name ? name + 1: argv[0])); - printf("Makes a device with the supplied 40-digit UDID enter recovery mode immediately.\n\n"); + printf("Makes a device with the supplied UDID enter recovery mode immediately.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -h, --help\t\tprints usage information\n"); printf("\n"); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) } i--; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (argc < 2 || !argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } 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': diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c index 40bcac6..59fade8 100644 --- a/tools/ideviceinfo.c +++ b/tools/ideviceinfo.c @@ -91,7 +91,7 @@ static void print_usage(int argc, char **argv) printf("Show information about a connected device.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -s, --simple\t\tuse a simple connection to avoid auto-pairing with the device\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(" -q, --domain NAME\tset domain of query to NAME. Default: None\n"); printf(" -k, --key NAME\tonly query key specified by NAME. Default: All keys.\n"); printf(" -x, --xml\t\toutput information as xml plist instead of key/value pairs\n"); @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicename.c b/tools/idevicename.c index 013becc..ef226f7 100644 --- a/tools/idevicename.c +++ b/tools/idevicename.c @@ -38,7 +38,7 @@ static void print_usage(void) printf("Display the device name or set it to NAME if specified.\n"); printf("\n"); printf(" -d, --debug\t\tenable communication debugging\n"); - printf(" -u, --udid UDID\tuse UDID to target a specific device\n"); + printf(" -u, --udid UDID\ttarget specific device by UDID\n"); printf(" -h, --help\t\tprint usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -60,6 +60,12 @@ int main(int argc, char** argv) while ((c = getopt_long(argc, argv, "du:h", longopts, &optidx)) != -1) { switch (c) { case 'u': + if (!*optarg) { + fprintf(stderr, "ERROR: UDID must not be empty!\n"); + print_usage(); + exit(2); + } + free(udid); udid = strdup(optarg); break; case 'h': diff --git a/tools/idevicenotificationproxy.c b/tools/idevicenotificationproxy.c index 5e4ac9a..72b406c 100644 --- a/tools/idevicenotificationproxy.c +++ b/tools/idevicenotificationproxy.c @@ -70,7 +70,7 @@ static void print_usage(int argc, char **argv) printf("\n"); printf(" The following OPTIONS are accepted:\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); result = 0; goto cleanup; diff --git a/tools/idevicepair.c b/tools/idevicepair.c index b6f0751..6ae9103 100644 --- a/tools/idevicepair.c +++ b/tools/idevicepair.c @@ -72,7 +72,7 @@ static void print_usage(int argc, char **argv) printf(" list list devices paired with this host\n\n"); printf(" The following OPTIONS are accepted:\n"); printf(" -d, --debug enable communication debugging\n"); - printf(" -u, --udid UDID target specific device by its 40-digit device UDID\n"); + printf(" -u, --udid UDID target specific device by UDID\n"); printf(" -h, --help prints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); @@ -81,9 +81,9 @@ 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", 1, NULL, 'u'}, - {"debug", 0, NULL, 'd'}, + {"help", no_argument, NULL, 'h'}, + {"udid", required_argument, NULL, 'u'}, + {"debug", no_argument, NULL, 'd'}, {NULL, 0, NULL, 0} }; int c; @@ -99,8 +99,8 @@ static void parse_opts(int argc, char **argv) print_usage(argc, argv); exit(EXIT_SUCCESS); 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); } diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c index 0bef7e8..f91ce4f 100644 --- a/tools/ideviceprovision.c +++ b/tools/ideviceprovision.c @@ -64,7 +64,7 @@ static void print_usage(int argc, char **argv) printf(" \tspecified by FILE.\n\n"); printf(" The following OPTIONS are accepted:\n"); printf(" -d, --debug enable communication debugging\n"); - printf(" -u, --udid UDID target specific device by its 40-digit device UDID\n"); + printf(" -u, --udid UDID target specific device by UDID\n"); printf(" -x, --xml print XML output when using the 'dump' command\n"); printf(" -h, --help prints usage information\n"); printf("\n"); @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c index 74acdf6..f2bcd48 100644 --- a/tools/idevicescreenshot.c +++ b/tools/idevicescreenshot.c @@ -55,7 +55,7 @@ int main(int argc, char **argv) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } @@ -158,7 +158,7 @@ void print_usage(int argc, char **argv) printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); printf("the screenshotr service is not available.\n\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index 0a923b8..76de128 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c @@ -185,7 +185,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; - if (!argv[i] || (strlen(argv[i]) != 40)) { + if (!argv[i] || !*argv[i]) { print_usage(argc, argv); return 0; } @@ -238,7 +238,7 @@ void print_usage(int argc, char **argv) printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); printf("Relay syslog of a connected device.\n\n"); printf(" -d, --debug\t\tenable communication debugging\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(" -h, --help\t\tprints usage information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); |