diff options
| author | 2012-09-09 15:28:17 +0200 | |
|---|---|---|
| committer | 2012-09-09 15:28:17 +0200 | |
| commit | 66a70a3d3a06b0d82d3392a72594c771b7d3c61b (patch) | |
| tree | 07424b31c2826c7032ab0066f397ba62a3a86eee /src | |
| parent | 60cf6780c399f71751b4748bcca84c41f1a0b722 (diff) | |
| download | ideviceinstaller-66a70a3d3a06b0d82d3392a72594c771b7d3c61b.tar.gz ideviceinstaller-66a70a3d3a06b0d82d3392a72594c771b7d3c61b.tar.bz2 | |
Fix Info.plist retrieval for .ipa where Payload is NOT the first entry
Diffstat (limited to 'src')
| -rw-r--r-- | src/ideviceinstaller.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index bde9d97..7b088c3 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c | |||
| @@ -620,8 +620,14 @@ run_again: | |||
| 620 | /* extract iTunesMetadata.plist from package */ | 620 | /* extract iTunesMetadata.plist from package */ |
| 621 | char *zbuf = NULL; | 621 | char *zbuf = NULL; |
| 622 | uint32_t len = 0; | 622 | uint32_t len = 0; |
| 623 | plist_t meta_dict = NULL; | ||
| 623 | if (zip_get_contents(zf, "iTunesMetadata.plist", 0, &zbuf, &len) == 0) { | 624 | if (zip_get_contents(zf, "iTunesMetadata.plist", 0, &zbuf, &len) == 0) { |
| 624 | meta = plist_new_data(zbuf, len); | 625 | meta = plist_new_data(zbuf, len); |
| 626 | if (memcmp(zbuf, "bplist00", 8) == 0) { | ||
| 627 | plist_from_bin(zbuf, len, &meta_dict); | ||
| 628 | } else { | ||
| 629 | plist_from_xml(zbuf, len, &meta_dict); | ||
| 630 | } | ||
| 625 | } | 631 | } |
| 626 | if (zbuf) { | 632 | if (zbuf) { |
| 627 | free(zbuf); | 633 | free(zbuf); |
| @@ -632,10 +638,11 @@ run_again: | |||
| 632 | zbuf = NULL; | 638 | zbuf = NULL; |
| 633 | len = 0; | 639 | len = 0; |
| 634 | char filename[256]; | 640 | char filename[256]; |
| 641 | filename[0] = '\0'; | ||
| 635 | 642 | ||
| 636 | /* check for "Payload" directory */ | 643 | /* check for "Payload" directory */ |
| 637 | strcpy(filename, zip_get_name(zf, 0, 0)); | 644 | int zindex = zip_name_locate(zf, "Payload/", 0); |
| 638 | if (strcmp(filename, "Payload") != 0) { | 645 | if (zindex < 0) { |
| 639 | fprintf(stderr, "Unable to locate Payload folder in archive!\n"); | 646 | fprintf(stderr, "Unable to locate Payload folder in archive!\n"); |
| 640 | zip_unchange_all(zf); | 647 | zip_unchange_all(zf); |
| 641 | zip_close(zf); | 648 | zip_close(zf); |
| @@ -643,7 +650,26 @@ run_again: | |||
| 643 | } | 650 | } |
| 644 | 651 | ||
| 645 | /* check for "*.app" directory */ | 652 | /* check for "*.app" directory */ |
| 646 | strcpy(filename, zip_get_name(zf, 1, 0)); | 653 | if (meta_dict) { |
| 654 | plist_t nm = plist_dict_get_item(meta_dict, "itemName"); | ||
| 655 | plist_t fe = plist_dict_get_item(meta_dict, "fileExtension"); | ||
| 656 | if (nm && (plist_get_node_type(nm) == PLIST_STRING) && fe && (plist_get_node_type(fe) == PLIST_STRING)) { | ||
| 657 | char* val = NULL; | ||
| 658 | plist_get_string_val(nm, &val); | ||
| 659 | if (val) { | ||
| 660 | strcpy(filename, "Payload/"); | ||
| 661 | strcat(filename, val); | ||
| 662 | free(val); | ||
| 663 | val = NULL; | ||
| 664 | plist_get_string_val(fe, &val); | ||
| 665 | strcat(filename, val); | ||
| 666 | strcat(filename, "/"); | ||
| 667 | } | ||
| 668 | } | ||
| 669 | } | ||
| 670 | if (filename[0] == '\0') { | ||
| 671 | strcpy(filename, zip_get_name(zf, zindex+1, 0)); | ||
| 672 | } | ||
| 647 | 673 | ||
| 648 | /* construct full filename to Info.plist */ | 674 | /* construct full filename to Info.plist */ |
| 649 | strcat(filename, "Info.plist"); | 675 | strcat(filename, "Info.plist"); |
