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) | |||
| 208 | */ | 208 | */ |
| 209 | userpref_error_t userpref_get_paired_udids(char ***list, unsigned int *count) | 209 | userpref_error_t userpref_get_paired_udids(char ***list, unsigned int *count) |
| 210 | { | 210 | { |
| 211 | struct slist_t { | ||
| 212 | char *name; | ||
| 213 | void *next; | ||
| 214 | }; | ||
| 215 | DIR *config_dir; | 211 | DIR *config_dir; |
| 216 | const char *config_path = NULL; | 212 | const char *config_path = NULL; |
| 217 | struct slist_t *udids = NULL; | ||
| 218 | unsigned int i; | ||
| 219 | unsigned int found = 0; | 213 | unsigned int found = 0; |
| 220 | 214 | ||
| 221 | if (!list || (list && *list)) { | 215 | if (!list || (list && *list)) { |
| @@ -226,41 +220,42 @@ userpref_error_t userpref_get_paired_udids(char ***list, unsigned int *count) | |||
| 226 | if (count) { | 220 | if (count) { |
| 227 | *count = 0; | 221 | *count = 0; |
| 228 | } | 222 | } |
| 223 | *list = (char**)malloc(sizeof(char*)); | ||
| 229 | 224 | ||
| 230 | config_path = userpref_get_config_dir(); | 225 | config_path = userpref_get_config_dir(); |
| 231 | config_dir = opendir(config_path); | 226 | config_dir = opendir(config_path); |
| 232 | if (config_dir) { | 227 | if (config_dir) { |
| 233 | struct dirent *entry; | 228 | struct dirent *entry; |
| 234 | struct slist_t *listp = udids; | ||
| 235 | while ((entry = readdir(config_dir))) { | 229 | while ((entry = readdir(config_dir))) { |
| 236 | char *ext = strstr(entry->d_name, USERPREF_CONFIG_EXTENSION); | 230 | if (strcmp(entry->d_name, USERPREF_CONFIG_FILE) == 0) { |
| 237 | if (ext && ((ext - entry->d_name) == 40) && (strlen(entry->d_name) == (40 + strlen(ext)))) { | 231 | /* ignore SystemConfiguration.plist */ |
| 238 | struct slist_t *ne = (struct slist_t*)malloc(sizeof(struct slist_t)); | 232 | continue; |
| 239 | ne->name = (char*)malloc(41); | 233 | } |
| 240 | strncpy(ne->name, entry->d_name, 40); | 234 | char *ext = strrchr(entry->d_name, '.'); |
| 241 | ne->name[40] = 0; | 235 | if (ext && (strcmp(ext, USERPREF_CONFIG_EXTENSION) == 0)) { |
| 242 | ne->next = NULL; | 236 | size_t len = strlen(entry->d_name) - strlen(USERPREF_CONFIG_EXTENSION); |
| 243 | if (!listp) { | 237 | char **newlist = (char**)realloc(*list, sizeof(char*) * (found+2)); |
| 244 | listp = ne; | 238 | if (!newlist) { |
| 245 | udids = listp; | 239 | fprintf(stderr, "ERROR: Out of memory\n"); |
| 246 | } else { | 240 | break; |
| 247 | listp->next = ne; | 241 | } |
| 248 | listp = listp->next; | 242 | *list = newlist; |
| 243 | char *tmp = (char*)malloc(len+1); | ||
| 244 | if (tmp) { | ||
| 245 | strncpy(tmp, entry->d_name, len); | ||
| 246 | tmp[len] = '\0'; | ||
| 247 | } | ||
| 248 | (*list)[found] = tmp; | ||
| 249 | if (!tmp) { | ||
| 250 | fprintf(stderr, "ERROR: Out of memory\n"); | ||
| 251 | break; | ||
| 249 | } | 252 | } |
| 250 | found++; | 253 | found++; |
| 251 | } | 254 | } |
| 252 | } | 255 | } |
| 253 | closedir(config_dir); | 256 | closedir(config_dir); |
| 254 | } | 257 | } |
| 255 | *list = (char**)malloc(sizeof(char*) * (found+1)); | 258 | (*list)[found] = NULL; |
| 256 | i = 0; | ||
| 257 | while (udids) { | ||
| 258 | (*list)[i++] = udids->name; | ||
| 259 | struct slist_t *old = udids; | ||
| 260 | udids = udids->next; | ||
| 261 | free(old); | ||
| 262 | } | ||
| 263 | (*list)[i] = NULL; | ||
| 264 | 259 | ||
| 265 | if (count) { | 260 | if (count) { |
| 266 | *count = found; | 261 | *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. | |||
| 8 | .SH DESCRIPTION | 8 | .SH DESCRIPTION |
| 9 | 9 | ||
| 10 | Prints device name or a list of attached devices. | 10 | Prints device name or a list of attached devices. |
| 11 | The UDID is a 40-digit hexadecimal number of the device | 11 | UDID is the unique device identifier of the device |
| 12 | for which the name should be retrieved. | 12 | for which the name should be retrieved. |
| 13 | 13 | ||
| 14 | .SH OPTIONS | 14 | .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. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by its 40-digit device UDID. | 15 | target specific device by UDID. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-d, \-\-debug | 17 | .B \-d, \-\-debug |
| 18 | enable communication debugging. | 18 | 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. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by its 40-digit device UDID. | 15 | target specific device by UDID. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-s, \-\-source UDID | 17 | .B \-s, \-\-source UDID |
| 18 | use backup data from device specified by UDID. | 18 | 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. | |||
| 25 | enable communication debugging. | 25 | enable communication debugging. |
| 26 | .TP | 26 | .TP |
| 27 | .B \-u, \-\-udid UDID | 27 | .B \-u, \-\-udid UDID |
| 28 | target specific device by its 40-digit device UDID. | 28 | target specific device by UDID. |
| 29 | .TP | 29 | .TP |
| 30 | .B \-h, \-\-help | 30 | .B \-h, \-\-help |
| 31 | prints usage information. | 31 | 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. | |||
| 15 | enable communication debugging. | 15 | enable communication debugging. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-u, \-\-udid UDID | 17 | .B \-u, \-\-udid UDID |
| 18 | target specific device by its 40-digit device UDID. | 18 | target specific device by UDID. |
| 19 | .TP | 19 | .TP |
| 20 | .B \-s, \-\-set TIMESTAMP | 20 | .B \-s, \-\-set TIMESTAMP |
| 21 | set UTC time described by TIMESTAMP | 21 | 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. | |||
| 17 | set environment variable NAME to VALUE. | 17 | set environment variable NAME to VALUE. |
| 18 | .TP | 18 | .TP |
| 19 | .B \-u, \-\-udid UDID | 19 | .B \-u, \-\-udid UDID |
| 20 | target specific device by its 40-digit device UDID. | 20 | target specific device by UDID. |
| 21 | .TP | 21 | .TP |
| 22 | .B \-d, \-\-debug | 22 | .B \-d, \-\-debug |
| 23 | enable communication debugging. | 23 | 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. | |||
| 17 | .SH OPTIONS | 17 | .SH OPTIONS |
| 18 | .TP | 18 | .TP |
| 19 | .B \-u, \-\-udid UDID | 19 | .B \-u, \-\-udid UDID |
| 20 | target specific device by its 40-digit device UDID. | 20 | target specific device by UDID. |
| 21 | .TP | 21 | .TP |
| 22 | .B \-d, \-\-debug | 22 | .B \-d, \-\-debug |
| 23 | enable communication debugging. | 23 | 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. | |||
| 16 | .SH OPTIONS | 16 | .SH OPTIONS |
| 17 | .TP | 17 | .TP |
| 18 | .B \-u, \-\-udid UDID | 18 | .B \-u, \-\-udid UDID |
| 19 | target specific device by its 40-digit device UDID. | 19 | target specific device by UDID. |
| 20 | .TP | 20 | .TP |
| 21 | .B \-d, \-\-debug | 21 | .B \-d, \-\-debug |
| 22 | enable communication debugging. | 22 | 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. | |||
| 7 | 7 | ||
| 8 | .SH DESCRIPTION | 8 | .SH DESCRIPTION |
| 9 | 9 | ||
| 10 | Makes a device with the supplied 40-digit UDID enter recovery mode immediately. | 10 | Makes a device with the supplied UDID enter recovery mode immediately. |
| 11 | 11 | ||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .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. | |||
| 15 | enable communication debugging. | 15 | enable communication debugging. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-u, \-\-udid UDID | 17 | .B \-u, \-\-udid UDID |
| 18 | target specific device by its 40-digit device UDID. | 18 | target specific device by UDID. |
| 19 | .TP | 19 | .TP |
| 20 | .B \-l, \-\-list | 20 | .B \-l, \-\-list |
| 21 | list mount information | 21 | 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. | |||
| 15 | enable communication debugging. | 15 | enable communication debugging. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-u, \-\-udid UDID | 17 | .B \-u, \-\-udid UDID |
| 18 | target specific device by its 40-digit device UDID. | 18 | target specific device by UDID. |
| 19 | .TP | 19 | .TP |
| 20 | .B \-q, \-\-domain NAME | 20 | .B \-q, \-\-domain NAME |
| 21 | set domain of query to NAME. Default: None. | 21 | 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. | |||
| 21 | enable communication debugging. | 21 | enable communication debugging. |
| 22 | .TP | 22 | .TP |
| 23 | .B \-u, \-\-udid UDID | 23 | .B \-u, \-\-udid UDID |
| 24 | target specific device by its 40-digit device UDID. | 24 | target specific device by UDID. |
| 25 | .TP | 25 | .TP |
| 26 | .B \-h, \-\-help | 26 | .B \-h, \-\-help |
| 27 | prints usage information | 27 | 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. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by its 40-digit device UDID. | 15 | target specific device by UDID. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-d, \-\-debug | 17 | .B \-d, \-\-debug |
| 18 | enable communication debugging. | 18 | 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. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by its 40-digit device UDID. | 15 | target specific device by UDID. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-d, \-\-debug | 17 | .B \-d, \-\-debug |
| 18 | enable communication debugging. | 18 | 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. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by its 40-digit device UDID. | 15 | target specific device by UDID. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-x, \-\-xml | 17 | .B \-x, \-\-xml |
| 18 | print XML output when using the 'dump' command. | 18 | 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. | |||
| 22 | enable communication debugging. | 22 | enable communication debugging. |
| 23 | .TP | 23 | .TP |
| 24 | .B \-u, \-\-udid UDID | 24 | .B \-u, \-\-udid UDID |
| 25 | target specific device by its 40-digit device UDID. | 25 | target specific device by UDID. |
| 26 | .TP | 26 | .TP |
| 27 | .B \-h, \-\-help | 27 | .B \-h, \-\-help |
| 28 | prints usage information | 28 | 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. | |||
| 15 | enable communication debugging. | 15 | enable communication debugging. |
| 16 | .TP | 16 | .TP |
| 17 | .B \-u, \-\-udid UDID | 17 | .B \-u, \-\-udid UDID |
| 18 | target specific device by its 40-digit device UDID | 18 | target specific device by UDID. |
| 19 | .TP | 19 | .TP |
| 20 | .B \-h, \-\-help | 20 | .B \-h, \-\-help |
| 21 | prints usage information. | 21 | 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) | |||
| 40 | name = strrchr(argv[0], '/'); | 40 | name = strrchr(argv[0], '/'); |
| 41 | printf("Usage: %s [OPTIONS] [UDID]\n", (name ? name + 1: argv[0])); | 41 | printf("Usage: %s [OPTIONS] [UDID]\n", (name ? name + 1: argv[0])); |
| 42 | printf("Prints device name or a list of attached devices.\n\n"); | 42 | printf("Prints device name or a list of attached devices.\n\n"); |
| 43 | printf(" The UDID is a 40-digit hexadecimal number of the device\n"); | 43 | printf(" UDID is the unique device identifier of the device\n"); |
| 44 | printf(" for which the name should be retrieved.\n\n"); | 44 | printf(" for which the name should be retrieved.\n\n"); |
| 45 | printf(" -l, --list\t\tlist UDID of all attached devices\n"); | 45 | printf(" -l, --list\t\tlist UDID of all attached devices\n"); |
| 46 | printf(" -d, --debug\t\tenable communication debugging\n"); | 46 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| @@ -79,7 +79,7 @@ int main(int argc, char **argv) | |||
| 79 | /* check if udid was passed */ | 79 | /* check if udid was passed */ |
| 80 | if (mode == MODE_SHOW_ID) { | 80 | if (mode == MODE_SHOW_ID) { |
| 81 | i--; | 81 | i--; |
| 82 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 82 | if (argc < 2 || !argv[i] || !*argv[i]) { |
| 83 | print_usage(argc, argv); | 83 | print_usage(argc, argv); |
| 84 | return 0; | 84 | return 0; |
| 85 | } | 85 | } |
| @@ -90,7 +90,7 @@ int main(int argc, char **argv) | |||
| 90 | case MODE_SHOW_ID: | 90 | case MODE_SHOW_ID: |
| 91 | idevice_new(&device, udid); | 91 | idevice_new(&device, udid); |
| 92 | if (!device) { | 92 | if (!device) { |
| 93 | fprintf(stderr, "ERROR: No device with UDID=%s attached.\n", udid); | 93 | fprintf(stderr, "ERROR: No device with UDID %s attached.\n", udid); |
| 94 | return -2; | 94 | return -2; |
| 95 | } | 95 | } |
| 96 | 96 | ||
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) | |||
| 671 | printf(" restore\tRestores a device backup from DIRECTORY.\n\n"); | 671 | printf(" restore\tRestores a device backup from DIRECTORY.\n\n"); |
| 672 | printf("options:\n"); | 672 | printf("options:\n"); |
| 673 | printf(" -d, --debug\t\tenable communication debugging\n"); | 673 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 674 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 674 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 675 | printf(" -h, --help\t\tprints usage information\n"); | 675 | printf(" -h, --help\t\tprints usage information\n"); |
| 676 | printf("\n"); | 676 | printf("\n"); |
| 677 | printf("Homepage: <" PACKAGE_URL ">\n"); | 677 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -715,7 +715,7 @@ int main(int argc, char *argv[]) | |||
| 715 | } | 715 | } |
| 716 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 716 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 717 | i++; | 717 | i++; |
| 718 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 718 | if (!argv[i] || !*argv[i]) { |
| 719 | print_usage(argc, argv); | 719 | print_usage(argc, argv); |
| 720 | return 0; | 720 | return 0; |
| 721 | } | 721 | } |
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) | |||
| 1323 | printf("\n"); | 1323 | printf("\n"); |
| 1324 | printf("options:\n"); | 1324 | printf("options:\n"); |
| 1325 | printf(" -d, --debug\t\tenable communication debugging\n"); | 1325 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 1326 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 1326 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 1327 | printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); | 1327 | printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); |
| 1328 | printf(" -i, --interactive\trequest passwords interactively\n"); | 1328 | printf(" -i, --interactive\trequest passwords interactively\n"); |
| 1329 | printf(" -h, --help\t\tprints usage information\n"); | 1329 | printf(" -h, --help\t\tprints usage information\n"); |
| @@ -1369,7 +1369,7 @@ int main(int argc, char *argv[]) | |||
| 1369 | } | 1369 | } |
| 1370 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 1370 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 1371 | i++; | 1371 | i++; |
| 1372 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 1372 | if (!argv[i] || !*argv[i]) { |
| 1373 | print_usage(argc, argv); | 1373 | print_usage(argc, argv); |
| 1374 | return -1; | 1374 | return -1; |
| 1375 | } | 1375 | } |
| @@ -1378,7 +1378,7 @@ int main(int argc, char *argv[]) | |||
| 1378 | } | 1378 | } |
| 1379 | else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--source")) { | 1379 | else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--source")) { |
| 1380 | i++; | 1380 | i++; |
| 1381 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 1381 | if (!argv[i] || !*argv[i]) { |
| 1382 | print_usage(argc, argv); | 1382 | print_usage(argc, argv); |
| 1383 | return -1; | 1383 | return -1; |
| 1384 | } | 1384 | } |
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) | |||
| 301 | printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n"); | 301 | printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n"); |
| 302 | printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n"); | 302 | printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n"); |
| 303 | printf(" -d, --debug\t\tenable communication debugging\n"); | 303 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 304 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 304 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 305 | printf(" -h, --help\t\tprints usage information\n"); | 305 | printf(" -h, --help\t\tprints usage information\n"); |
| 306 | printf("\n"); | 306 | printf("\n"); |
| 307 | printf("Homepage: <" PACKAGE_URL ">\n"); | 307 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -327,7 +327,7 @@ int main(int argc, char* argv[]) { | |||
| 327 | } | 327 | } |
| 328 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 328 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 329 | i++; | 329 | i++; |
| 330 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 330 | if (!argv[i] || !*argv[i]) { |
| 331 | print_usage(argc, argv); | 331 | print_usage(argc, argv); |
| 332 | return 0; | 332 | return 0; |
| 333 | } | 333 | } |
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) | |||
| 50 | printf("NOTE: Setting the time on iOS 6 and later is only supported\n"); | 50 | printf("NOTE: Setting the time on iOS 6 and later is only supported\n"); |
| 51 | printf(" in the setup wizard screens before device activation.\n\n"); | 51 | printf(" in the setup wizard screens before device activation.\n\n"); |
| 52 | printf(" -d, --debug\t\tenable communication debugging\n"); | 52 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 53 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 53 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 54 | printf(" -s, --set TIMESTAMP\tset UTC time described by TIMESTAMP\n"); | 54 | printf(" -s, --set TIMESTAMP\tset UTC time described by TIMESTAMP\n"); |
| 55 | printf(" -c, --sync\t\tset time of device to current system time\n"); | 55 | printf(" -c, --sync\t\tset time of device to current system time\n"); |
| 56 | printf(" -h, --help\t\tprints usage information\n"); | 56 | printf(" -h, --help\t\tprints usage information\n"); |
| @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) | |||
| 84 | } | 84 | } |
| 85 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 85 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 86 | i++; | 86 | i++; |
| 87 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 87 | if (!argv[i] || !*argv[i]) { |
| 88 | print_usage(argc, argv); | 88 | print_usage(argc, argv); |
| 89 | return 0; | 89 | return 0; |
| 90 | } | 90 | } |
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) | |||
| 188 | printf("\n"); | 188 | printf("\n"); |
| 189 | printf(" The following OPTIONS are accepted:\n"); | 189 | printf(" The following OPTIONS are accepted:\n"); |
| 190 | printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n"); | 190 | printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n"); |
| 191 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 191 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 192 | printf(" -d, --debug\t\tenable communication debugging\n"); | 192 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 193 | printf(" -h, --help\t\tprints usage information\n"); | 193 | printf(" -h, --help\t\tprints usage information\n"); |
| 194 | printf("\n"); | 194 | printf("\n"); |
| @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) | |||
| 233 | continue; | 233 | continue; |
| 234 | } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 234 | } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 235 | i++; | 235 | i++; |
| 236 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 236 | if (!argv[i] || !*argv[i]) { |
| 237 | print_usage(argc, argv); | 237 | print_usage(argc, argv); |
| 238 | res = 0; | 238 | res = 0; |
| 239 | goto cleanup; | 239 | 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) | |||
| 71 | printf("Usage: %s [OPTIONS] <PORT>\n", (name ? name + 1: argv[0])); | 71 | printf("Usage: %s [OPTIONS] <PORT>\n", (name ? name + 1: argv[0])); |
| 72 | printf("Proxy debugserver connection from device to a local socket at PORT.\n\n"); | 72 | printf("Proxy debugserver connection from device to a local socket at PORT.\n\n"); |
| 73 | printf(" -d, --debug\t\tenable communication debugging\n"); | 73 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 74 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 74 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 75 | printf(" -h, --help\t\tprints usage information\n"); | 75 | printf(" -h, --help\t\tprints usage information\n"); |
| 76 | printf("\n"); | 76 | printf("\n"); |
| 77 | printf("Homepage: <" PACKAGE_URL ">\n"); | 77 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -280,7 +280,7 @@ int main(int argc, char *argv[]) | |||
| 280 | } | 280 | } |
| 281 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 281 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 282 | i++; | 282 | i++; |
| 283 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 283 | if (!argv[i] || !*argv[i]) { |
| 284 | print_usage(argc, argv); | 284 | print_usage(argc, argv); |
| 285 | return 0; | 285 | return 0; |
| 286 | } | 286 | } |
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) | |||
| 79 | } | 79 | } |
| 80 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 80 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 81 | i++; | 81 | i++; |
| 82 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 82 | if (!argv[i] || !*argv[i]) { |
| 83 | print_usage(argc, argv); | 83 | print_usage(argc, argv); |
| 84 | result = 0; | 84 | result = 0; |
| 85 | goto cleanup; | 85 | goto cleanup; |
| @@ -318,7 +318,7 @@ void print_usage(int argc, char **argv) | |||
| 318 | printf(" sleep\t\t\t\tput device into sleep mode (disconnects from host)\n\n"); | 318 | printf(" sleep\t\t\t\tput device into sleep mode (disconnects from host)\n\n"); |
| 319 | printf(" The following OPTIONS are accepted:\n"); | 319 | printf(" The following OPTIONS are accepted:\n"); |
| 320 | printf(" -d, --debug\t\tenable communication debugging\n"); | 320 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 321 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 321 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 322 | printf(" -h, --help\t\tprints usage information\n"); | 322 | printf(" -h, --help\t\tprints usage information\n"); |
| 323 | printf("\n"); | 323 | printf("\n"); |
| 324 | printf("Homepage: <" PACKAGE_URL ">\n"); | 324 | 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) | |||
| 37 | 37 | ||
| 38 | name = strrchr(argv[0], '/'); | 38 | name = strrchr(argv[0], '/'); |
| 39 | printf("Usage: %s [OPTIONS] UDID\n", (name ? name + 1: argv[0])); | 39 | printf("Usage: %s [OPTIONS] UDID\n", (name ? name + 1: argv[0])); |
| 40 | printf("Makes a device with the supplied 40-digit UDID enter recovery mode immediately.\n\n"); | 40 | printf("Makes a device with the supplied UDID enter recovery mode immediately.\n\n"); |
| 41 | printf(" -d, --debug\t\tenable communication debugging\n"); | 41 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 42 | printf(" -h, --help\t\tprints usage information\n"); | 42 | printf(" -h, --help\t\tprints usage information\n"); |
| 43 | printf("\n"); | 43 | printf("\n"); |
| @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | i--; | 68 | i--; |
| 69 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 69 | if (argc < 2 || !argv[i] || !*argv[i]) { |
| 70 | print_usage(argc, argv); | 70 | print_usage(argc, argv); |
| 71 | return 0; | 71 | return 0; |
| 72 | } | 72 | } |
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) | |||
| 63 | name = strrchr(argv[0], '/'); | 63 | name = strrchr(argv[0], '/'); |
| 64 | printf("Usage: %s [OPTIONS] IMAGE_FILE IMAGE_SIGNATURE_FILE\n\n", (name ? name + 1: argv[0])); | 64 | printf("Usage: %s [OPTIONS] IMAGE_FILE IMAGE_SIGNATURE_FILE\n\n", (name ? name + 1: argv[0])); |
| 65 | printf("Mounts the specified disk image on the device.\n\n"); | 65 | printf("Mounts the specified disk image on the device.\n\n"); |
| 66 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 66 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 67 | printf(" -l, --list\t\tList mount information\n"); | 67 | printf(" -l, --list\t\tList mount information\n"); |
| 68 | printf(" -t, --imagetype\tImage type to use, default is 'Developer'\n"); | 68 | printf(" -t, --imagetype\tImage type to use, default is 'Developer'\n"); |
| 69 | printf(" -x, --xml\t\tUse XML output\n"); | 69 | printf(" -x, --xml\t\tUse XML output\n"); |
| @@ -76,19 +76,18 @@ static void print_usage(int argc, char **argv) | |||
| 76 | static void parse_opts(int argc, char **argv) | 76 | static void parse_opts(int argc, char **argv) |
| 77 | { | 77 | { |
| 78 | static struct option longopts[] = { | 78 | static struct option longopts[] = { |
| 79 | {"help", 0, NULL, 'h'}, | 79 | {"help", no_argument, NULL, 'h'}, |
| 80 | {"udid", 0, NULL, 'u'}, | 80 | {"udid", required_argument, NULL, 'u'}, |
| 81 | {"list", 0, NULL, 'l'}, | 81 | {"list", no_argument, NULL, 'l'}, |
| 82 | {"imagetype", 0, NULL, 't'}, | 82 | {"imagetype", required_argument, NULL, 't'}, |
| 83 | {"xml", 0, NULL, 'x'}, | 83 | {"xml", no_argument, NULL, 'x'}, |
| 84 | {"debug", 0, NULL, 'd'}, | 84 | {"debug", no_argument, NULL, 'd'}, |
| 85 | {NULL, 0, NULL, 0} | 85 | {NULL, 0, NULL, 0} |
| 86 | }; | 86 | }; |
| 87 | int c; | 87 | int c; |
| 88 | 88 | ||
| 89 | while (1) { | 89 | while (1) { |
| 90 | c = getopt_long(argc, argv, "hu:lt:xd", longopts, | 90 | c = getopt_long(argc, argv, "hu:lt:xd", longopts, NULL); |
| 91 | (int *) 0); | ||
| 92 | if (c == -1) { | 91 | if (c == -1) { |
| 93 | break; | 92 | break; |
| 94 | } | 93 | } |
| @@ -98,14 +97,12 @@ static void parse_opts(int argc, char **argv) | |||
| 98 | print_usage(argc, argv); | 97 | print_usage(argc, argv); |
| 99 | exit(0); | 98 | exit(0); |
| 100 | case 'u': | 99 | case 'u': |
| 101 | if (strlen(optarg) != 40) { | 100 | if (!*optarg) { |
| 102 | printf("%s: invalid UDID specified (length != 40)\n", | 101 | fprintf(stderr, "ERROR: UDID must not be empty!\n"); |
| 103 | argv[0]); | ||
| 104 | print_usage(argc, argv); | 102 | print_usage(argc, argv); |
| 105 | exit(2); | 103 | exit(2); |
| 106 | } | 104 | } |
| 107 | if (udid) | 105 | free(udid); |
| 108 | free(udid); | ||
| 109 | udid = strdup(optarg); | 106 | udid = strdup(optarg); |
| 110 | break; | 107 | break; |
| 111 | case 'l': | 108 | 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) | |||
| 91 | printf("Show information about a connected device.\n\n"); | 91 | printf("Show information about a connected device.\n\n"); |
| 92 | printf(" -d, --debug\t\tenable communication debugging\n"); | 92 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 93 | printf(" -s, --simple\t\tuse a simple connection to avoid auto-pairing with the device\n"); | 93 | printf(" -s, --simple\t\tuse a simple connection to avoid auto-pairing with the device\n"); |
| 94 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 94 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 95 | printf(" -q, --domain NAME\tset domain of query to NAME. Default: None\n"); | 95 | printf(" -q, --domain NAME\tset domain of query to NAME. Default: None\n"); |
| 96 | printf(" -k, --key NAME\tonly query key specified by NAME. Default: All keys.\n"); | 96 | printf(" -k, --key NAME\tonly query key specified by NAME. Default: All keys.\n"); |
| 97 | printf(" -x, --xml\t\toutput information as xml plist instead of key/value pairs\n"); | 97 | 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[]) | |||
| 129 | } | 129 | } |
| 130 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 130 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 131 | i++; | 131 | i++; |
| 132 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 132 | if (!argv[i] || !*argv[i]) { |
| 133 | print_usage(argc, argv); | 133 | print_usage(argc, argv); |
| 134 | return 0; | 134 | return 0; |
| 135 | } | 135 | } |
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) | |||
| 38 | printf("Display the device name or set it to NAME if specified.\n"); | 38 | printf("Display the device name or set it to NAME if specified.\n"); |
| 39 | printf("\n"); | 39 | printf("\n"); |
| 40 | printf(" -d, --debug\t\tenable communication debugging\n"); | 40 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 41 | printf(" -u, --udid UDID\tuse UDID to target a specific device\n"); | 41 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 42 | printf(" -h, --help\t\tprint usage information\n"); | 42 | printf(" -h, --help\t\tprint usage information\n"); |
| 43 | printf("\n"); | 43 | printf("\n"); |
| 44 | printf("Homepage: <" PACKAGE_URL ">\n"); | 44 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -60,6 +60,12 @@ int main(int argc, char** argv) | |||
| 60 | while ((c = getopt_long(argc, argv, "du:h", longopts, &optidx)) != -1) { | 60 | while ((c = getopt_long(argc, argv, "du:h", longopts, &optidx)) != -1) { |
| 61 | switch (c) { | 61 | switch (c) { |
| 62 | case 'u': | 62 | case 'u': |
| 63 | if (!*optarg) { | ||
| 64 | fprintf(stderr, "ERROR: UDID must not be empty!\n"); | ||
| 65 | print_usage(); | ||
| 66 | exit(2); | ||
| 67 | } | ||
| 68 | free(udid); | ||
| 63 | udid = strdup(optarg); | 69 | udid = strdup(optarg); |
| 64 | break; | 70 | break; |
| 65 | case 'h': | 71 | 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) | |||
| 70 | printf("\n"); | 70 | printf("\n"); |
| 71 | printf(" The following OPTIONS are accepted:\n"); | 71 | printf(" The following OPTIONS are accepted:\n"); |
| 72 | printf(" -d, --debug\t\tenable communication debugging\n"); | 72 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 73 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 73 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 74 | printf(" -h, --help\t\tprints usage information\n"); | 74 | printf(" -h, --help\t\tprints usage information\n"); |
| 75 | printf("\n"); | 75 | printf("\n"); |
| 76 | printf("Homepage: <" PACKAGE_URL ">\n"); | 76 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) | |||
| 114 | } | 114 | } |
| 115 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 115 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 116 | i++; | 116 | i++; |
| 117 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 117 | if (!argv[i] || !*argv[i]) { |
| 118 | print_usage(argc, argv); | 118 | print_usage(argc, argv); |
| 119 | result = 0; | 119 | result = 0; |
| 120 | goto cleanup; | 120 | 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) | |||
| 72 | printf(" list list devices paired with this host\n\n"); | 72 | printf(" list list devices paired with this host\n\n"); |
| 73 | printf(" The following OPTIONS are accepted:\n"); | 73 | printf(" The following OPTIONS are accepted:\n"); |
| 74 | printf(" -d, --debug enable communication debugging\n"); | 74 | printf(" -d, --debug enable communication debugging\n"); |
| 75 | printf(" -u, --udid UDID target specific device by its 40-digit device UDID\n"); | 75 | printf(" -u, --udid UDID target specific device by UDID\n"); |
| 76 | printf(" -h, --help prints usage information\n"); | 76 | printf(" -h, --help prints usage information\n"); |
| 77 | printf("\n"); | 77 | printf("\n"); |
| 78 | printf("Homepage: <" PACKAGE_URL ">\n"); | 78 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| @@ -81,9 +81,9 @@ static void print_usage(int argc, char **argv) | |||
| 81 | static void parse_opts(int argc, char **argv) | 81 | static void parse_opts(int argc, char **argv) |
| 82 | { | 82 | { |
| 83 | static struct option longopts[] = { | 83 | static struct option longopts[] = { |
| 84 | {"help", 0, NULL, 'h'}, | 84 | {"help", no_argument, NULL, 'h'}, |
| 85 | {"udid", 1, NULL, 'u'}, | 85 | {"udid", required_argument, NULL, 'u'}, |
| 86 | {"debug", 0, NULL, 'd'}, | 86 | {"debug", no_argument, NULL, 'd'}, |
| 87 | {NULL, 0, NULL, 0} | 87 | {NULL, 0, NULL, 0} |
| 88 | }; | 88 | }; |
| 89 | int c; | 89 | int c; |
| @@ -99,8 +99,8 @@ static void parse_opts(int argc, char **argv) | |||
| 99 | print_usage(argc, argv); | 99 | print_usage(argc, argv); |
| 100 | exit(EXIT_SUCCESS); | 100 | exit(EXIT_SUCCESS); |
| 101 | case 'u': | 101 | case 'u': |
| 102 | if (strlen(optarg) != 40) { | 102 | if (!*optarg) { |
| 103 | printf("%s: invalid UDID specified (length != 40)\n", argv[0]); | 103 | fprintf(stderr, "ERROR: UDID must not be empty!\n"); |
| 104 | print_usage(argc, argv); | 104 | print_usage(argc, argv); |
| 105 | exit(2); | 105 | exit(2); |
| 106 | } | 106 | } |
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) | |||
| 64 | printf(" \tspecified by FILE.\n\n"); | 64 | printf(" \tspecified by FILE.\n\n"); |
| 65 | printf(" The following OPTIONS are accepted:\n"); | 65 | printf(" The following OPTIONS are accepted:\n"); |
| 66 | printf(" -d, --debug enable communication debugging\n"); | 66 | printf(" -d, --debug enable communication debugging\n"); |
| 67 | printf(" -u, --udid UDID target specific device by its 40-digit device UDID\n"); | 67 | printf(" -u, --udid UDID target specific device by UDID\n"); |
| 68 | printf(" -x, --xml print XML output when using the 'dump' command\n"); | 68 | printf(" -x, --xml print XML output when using the 'dump' command\n"); |
| 69 | printf(" -h, --help prints usage information\n"); | 69 | printf(" -h, --help prints usage information\n"); |
| 70 | printf("\n"); | 70 | printf("\n"); |
| @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) | |||
| 299 | } | 299 | } |
| 300 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 300 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 301 | i++; | 301 | i++; |
| 302 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 302 | if (!argv[i] || !*argv[i]) { |
| 303 | print_usage(argc, argv); | 303 | print_usage(argc, argv); |
| 304 | return 0; | 304 | return 0; |
| 305 | } | 305 | } |
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) | |||
| 55 | } | 55 | } |
| 56 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 56 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 57 | i++; | 57 | i++; |
| 58 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 58 | if (!argv[i] || !*argv[i]) { |
| 59 | print_usage(argc, argv); | 59 | print_usage(argc, argv); |
| 60 | return 0; | 60 | return 0; |
| 61 | } | 61 | } |
| @@ -158,7 +158,7 @@ void print_usage(int argc, char **argv) | |||
| 158 | printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); | 158 | printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); |
| 159 | printf("the screenshotr service is not available.\n\n"); | 159 | printf("the screenshotr service is not available.\n\n"); |
| 160 | printf(" -d, --debug\t\tenable communication debugging\n"); | 160 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 161 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 161 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 162 | printf(" -h, --help\t\tprints usage information\n"); | 162 | printf(" -h, --help\t\tprints usage information\n"); |
| 163 | printf("\n"); | 163 | printf("\n"); |
| 164 | printf("Homepage: <" PACKAGE_URL ">\n"); | 164 | 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[]) | |||
| 185 | } | 185 | } |
| 186 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { | 186 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { |
| 187 | i++; | 187 | i++; |
| 188 | if (!argv[i] || (strlen(argv[i]) != 40)) { | 188 | if (!argv[i] || !*argv[i]) { |
| 189 | print_usage(argc, argv); | 189 | print_usage(argc, argv); |
| 190 | return 0; | 190 | return 0; |
| 191 | } | 191 | } |
| @@ -238,7 +238,7 @@ void print_usage(int argc, char **argv) | |||
| 238 | printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); | 238 | printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); |
| 239 | printf("Relay syslog of a connected device.\n\n"); | 239 | printf("Relay syslog of a connected device.\n\n"); |
| 240 | printf(" -d, --debug\t\tenable communication debugging\n"); | 240 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 241 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 241 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 242 | printf(" -h, --help\t\tprints usage information\n"); | 242 | printf(" -h, --help\t\tprints usage information\n"); |
| 243 | printf("\n"); | 243 | printf("\n"); |
| 244 | printf("Homepage: <" PACKAGE_URL ">\n"); | 244 | printf("Homepage: <" PACKAGE_URL ">\n"); |
