diff options
author | Aaron Burghardt | 2013-10-01 06:12:26 -0400 |
---|---|---|
committer | Martin Szulecki | 2013-10-24 14:39:46 +0200 |
commit | a915466200f3105949fd4c95d1b5b2087a6c7e6b (patch) | |
tree | 745886872648516d04e78f7f36c48006b6d87254 /src | |
parent | 926b77a9fbb58f3020cf5c67921d727f5ff51266 (diff) | |
download | idevicerestore-a915466200f3105949fd4c95d1b5b2087a6c7e6b.tar.gz idevicerestore-a915466200f3105949fd4c95d1b5b2087a6c7e6b.tar.bz2 |
Prefer the WTF file in the restore IPSW, fallback to downloading the WTF IPSW.
Signed-off-by: Martin Szulecki <m.szulecki@libimobiledevice.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/idevicerestore.c | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c index c32db88..b27ea8c 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -207,47 +207,55 @@ int idevicerestore_start(struct idevicerestore_client_t* client) return -1; } - char* s_wtfurl = NULL; - plist_t wtfurl = plist_access_path(client->version_data, 7, "MobileDeviceSoftwareVersionsByVersion", "5", "RecoverySoftwareVersions", "WTF", "304218112", "5", "FirmwareURL"); - if (wtfurl && (plist_get_node_type(wtfurl) == PLIST_STRING)) { - plist_get_string_val(wtfurl, &s_wtfurl); - } - if (!s_wtfurl) { - info("Using hardcoded x12220000_5_Recovery.ipsw URL\n"); - s_wtfurl = strdup("http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-6618.20090617.Xse7Y/x12220000_5_Recovery.ipsw"); - } - - // make a local file name - char* fnpart = strrchr(s_wtfurl, '/'); - if (!fnpart) { - fnpart = "x12220000_5_Recovery.ipsw"; - } else { - fnpart++; - } - struct stat fst; - char wtfipsw[1024]; - if (client->cache_dir) { - if (stat(client->cache_dir, &fst) < 0) { - mkdir_with_parents(client->cache_dir, 0755); - } - strcpy(wtfipsw, client->cache_dir); - strcat(wtfipsw, "/"); - strcat(wtfipsw, fnpart); - } else { - strcpy(wtfipsw, fnpart); - } - if (stat(wtfipsw, &fst) != 0) { - download_to_file(s_wtfurl, wtfipsw, 0); - } - char wtfname[256]; sprintf(wtfname, "Firmware/dfu/WTF.s5l%04xxall.RELEASE.dfu", cpid); unsigned char* wtftmp = NULL; unsigned int wtfsize = 0; - ipsw_extract_to_memory(wtfipsw, wtfname, &wtftmp, &wtfsize); + + // Prefer to get WTF file from the restore IPSW + ipsw_extract_to_memory(client->ipsw, wtfname, &wtftmp, &wtfsize); if (!wtftmp) { - error("ERROR: Could not extract WTF\n"); - } else { + // Download WTF IPSW + char* s_wtfurl = NULL; + plist_t wtfurl = plist_access_path(client->version_data, 7, "MobileDeviceSoftwareVersionsByVersion", "5", "RecoverySoftwareVersions", "WTF", "304218112", "5", "FirmwareURL"); + if (wtfurl && (plist_get_node_type(wtfurl) == PLIST_STRING)) { + plist_get_string_val(wtfurl, &s_wtfurl); + } + if (!s_wtfurl) { + info("Using hardcoded x12220000_5_Recovery.ipsw URL\n"); + s_wtfurl = strdup("http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-6618.20090617.Xse7Y/x12220000_5_Recovery.ipsw"); + } + + // make a local file name + char* fnpart = strrchr(s_wtfurl, '/'); + if (!fnpart) { + fnpart = "x12220000_5_Recovery.ipsw"; + } else { + fnpart++; + } + struct stat fst; + char wtfipsw[1024]; + if (client->cache_dir) { + if (stat(client->cache_dir, &fst) < 0) { + mkdir_with_parents(client->cache_dir, 0755); + } + strcpy(wtfipsw, client->cache_dir); + strcat(wtfipsw, "/"); + strcat(wtfipsw, fnpart); + } else { + strcpy(wtfipsw, fnpart); + } + if (stat(wtfipsw, &fst) != 0) { + download_to_file(s_wtfurl, wtfipsw, 0); + } + + ipsw_extract_to_memory(wtfipsw, wtfname, &wtftmp, &wtfsize); + if (!wtftmp) { + error("ERROR: Could not extract WTF\n"); + } + } + + if (wtftmp) { if (dfu_send_buffer(client, wtftmp, wtfsize) != 0) { error("ERROR: Could not send WTF...\n"); } |