diff options
| author | 2016-12-01 03:52:16 +0100 | |
|---|---|---|
| committer | 2016-12-01 03:52:16 +0100 | |
| commit | 9083475cd899a09040b265863fcfee0b390c89b3 (patch) | |
| tree | 12a4b683584bb41afd119ad6b6cc5cf9e8edb747 /tools | |
| parent | 76def2b68e7f2fbfc02315d29284fd74dabed8dc (diff) | |
| download | libimobiledevice-9083475cd899a09040b265863fcfee0b390c89b3.tar.gz libimobiledevice-9083475cd899a09040b265863fcfee0b390c89b3.tar.bz2 | |
ideviceprovision: Check output directory parameter for 'copy' command and return exit code on error
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/ideviceprovision.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c index 77c27dc..7938580 100644 --- a/tools/ideviceprovision.c +++ b/tools/ideviceprovision.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
| 29 | #include <string.h> | 29 | #include <string.h> |
| 30 | #include <errno.h> | ||
| 30 | 31 | ||
| 31 | #ifdef WIN32 | 32 | #ifdef WIN32 |
| 32 | #include <windows.h> | 33 | #include <windows.h> |
| @@ -254,6 +255,7 @@ int main(int argc, char *argv[]) | |||
| 254 | lockdownd_service_descriptor_t service = NULL; | 255 | lockdownd_service_descriptor_t service = NULL; |
| 255 | idevice_t device = NULL; | 256 | idevice_t device = NULL; |
| 256 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; | 257 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; |
| 258 | int res = 0; | ||
| 257 | int i; | 259 | int i; |
| 258 | int op = -1; | 260 | int op = -1; |
| 259 | int output_xml = 0; | 261 | int output_xml = 0; |
| @@ -338,7 +340,6 @@ int main(int argc, char *argv[]) | |||
| 338 | } | 340 | } |
| 339 | 341 | ||
| 340 | if (op == OP_DUMP) { | 342 | if (op == OP_DUMP) { |
| 341 | int res = 0; | ||
| 342 | unsigned char* profile_data = NULL; | 343 | unsigned char* profile_data = NULL; |
| 343 | unsigned int profile_size = 0; | 344 | unsigned int profile_size = 0; |
| 344 | if (profile_read_from_file(param, &profile_data, &profile_size) != 0) { | 345 | if (profile_read_from_file(param, &profile_data, &profile_size) != 0) { |
| @@ -372,6 +373,12 @@ int main(int argc, char *argv[]) | |||
| 372 | plist_free(pl); | 373 | plist_free(pl); |
| 373 | 374 | ||
| 374 | return res; | 375 | return res; |
| 376 | } else if (op == OP_COPY) { | ||
| 377 | struct stat st; | ||
| 378 | if ((stat(param, &st) < 0) || !S_ISDIR(st.st_mode)) { | ||
| 379 | fprintf(stderr, "ERROR: %s does not exist or is not a directory!\n", param); | ||
| 380 | return -1; | ||
| 381 | } | ||
| 375 | } | 382 | } |
| 376 | 383 | ||
| 377 | ret = idevice_new(&device, udid); | 384 | ret = idevice_new(&device, udid); |
| @@ -502,19 +509,16 @@ int main(int argc, char *argv[]) | |||
| 502 | fclose(f); | 509 | fclose(f); |
| 503 | printf(" => %s\n", pfname); | 510 | printf(" => %s\n", pfname); |
| 504 | } else { | 511 | } else { |
| 505 | fprintf(stderr, "Could not open '%s' for writing\n", pfname); | 512 | fprintf(stderr, "Could not open '%s' for writing: %s\n", pfname, strerror(errno)); |
| 506 | } | 513 | } |
| 507 | } | 514 | } |
| 508 | if (p_uuid) { | 515 | free(p_uuid); |
| 509 | free(p_uuid); | 516 | free(p_name); |
| 510 | } | ||
| 511 | if (p_name) { | ||
| 512 | free(p_name); | ||
| 513 | } | ||
| 514 | } | 517 | } |
| 515 | } else { | 518 | } else { |
| 516 | int sc = misagent_get_status_code(mis); | 519 | int sc = misagent_get_status_code(mis); |
| 517 | fprintf(stderr, "Could not get installed profiles from device, status code: 0x%x\n", sc); | 520 | fprintf(stderr, "Could not get installed profiles from device, status code: 0x%x\n", sc); |
| 521 | res = -1; | ||
| 518 | } | 522 | } |
| 519 | } | 523 | } |
| 520 | break; | 524 | break; |
| @@ -534,6 +538,6 @@ int main(int argc, char *argv[]) | |||
| 534 | 538 | ||
| 535 | idevice_free(device); | 539 | idevice_free(device); |
| 536 | 540 | ||
| 537 | return 0; | 541 | return res; |
| 538 | } | 542 | } |
| 539 | 543 | ||
