diff options
author | Nikias Bassen | 2023-11-02 12:54:47 +0100 |
---|---|---|
committer | Nikias Bassen | 2023-11-02 12:54:47 +0100 |
commit | c871c591e36d2a4083e3dda4c70144a0321ce70f (patch) | |
tree | ce6a990c037c78a84a5d2f99038a7e98e1425bf6 /src/asr.c | |
parent | 4072cd965eab44993700b980d8848b46ec3be72e (diff) | |
download | idevicerestore-c871c591e36d2a4083e3dda4c70144a0321ce70f.tar.gz idevicerestore-c871c591e36d2a4083e3dda4c70144a0321ce70f.tar.bz2 |
Extract OS component when using older ipsw archives
Older ipsw archives have the root filesystem stored in compressed
format rather than just "stored". The "Verifying Filesystem" step
would then fail as compressed files are not seekable in ZIP files.
This commit introduces a detection for this and has the filesystem
extracted should it be required.
If not using a cache path, the temp file used for extraction will
be deleted after the procedure is completed.
Diffstat (limited to 'src/asr.c')
-rw-r--r-- | src/asr.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -216,9 +216,7 @@ int asr_perform_validation(asr_client_t asr, ipsw_file_handle_t file) plist_t payload_info = NULL; int attempts = 0; - ipsw_file_seek(file, 0, SEEK_END); - length = ipsw_file_tell(file); - ipsw_file_seek(file, 0, SEEK_SET); + length = ipsw_file_size(file); payload_info = plist_new_dict(); plist_dict_set_item(payload_info, "Port", plist_new_uint(1)); @@ -313,9 +311,14 @@ int asr_handle_oob_data_request(asr_client_t asr, plist_t packet, ipsw_file_hand return -1; } - ipsw_file_seek(file, oob_offset, SEEK_SET); - if (ipsw_file_read(file, oob_data, oob_length) != oob_length) { - error("ERROR: Unable to read OOB data from filesystem offset: %s\n", strerror(errno)); + if (ipsw_file_seek(file, oob_offset, SEEK_SET) < 0) { + error("ERROR: Unable to seek to OOB offset 0x%" PRIx64 "\n", oob_offset); + free(oob_data); + return -1; + } + int64_t ir = ipsw_file_read(file, oob_data, oob_length); + if (ir != oob_length) { + error("ERROR: Unable to read OOB data from filesystem offset 0x%" PRIx64 ", oob_length %" PRIu64 ", read returned %" PRIi64"\n", oob_offset, oob_length, ir); free(oob_data); return -1; } @@ -335,8 +338,7 @@ int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file) uint64_t i, length, bytes = 0; double progress = 0; - ipsw_file_seek(file, 0, SEEK_END); - length = ipsw_file_tell(file); + length = ipsw_file_size(file); ipsw_file_seek(file, 0, SEEK_SET); data = (char*)malloc(ASR_PAYLOAD_CHUNK_SIZE + 20); |