summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-09-29 15:46:49 +0200
committerGravatar Nikias Bassen2025-09-29 15:46:49 +0200
commit551dba57e3d38c721f474ae0cdbb4fe42ec4d66b (patch)
tree399408bedfd006e8bee925caebbd9ac5d6781983 /src
parent4cf940b9680b94f8d2f1dbd573f1eb2d56574b0a (diff)
downloadidevicerestore-551dba57e3d38c721f474ae0cdbb4fe42ec4d66b.tar.gz
idevicerestore-551dba57e3d38c721f474ae0cdbb4fe42ec4d66b.tar.bz2
Fix Mav baseband stitching
Diffstat (limited to 'src')
-rw-r--r--src/mbn.c15
-rw-r--r--src/restore.c6
2 files changed, 11 insertions, 10 deletions
diff --git a/src/mbn.c b/src/mbn.c
index 2ba5e65..ca51fdf 100644
--- a/src/mbn.c
+++ b/src/mbn.c
@@ -263,11 +263,11 @@ void* mbn_stitch(const void* data, size_t data_size, const void* blob, size_t bl
off_t stitch_offset = data_size - blob_size;
if (stitch_offset + blob_size > data_size) {
- logger(LL_ERROR, "%s: stitch offset (0x%llx) + size (0x%zx) is larger than the destination (0x%zx)\n", __func__, stitch_offset, blob_size, data_size);
+ logger(LL_ERROR, "%s: stitch offset (0x%lx) + size (0x%zx) is larger than the destination (0x%zx)\n", __func__, (unsigned long)stitch_offset, blob_size, data_size);
return NULL;
}
- void* buf = malloc(data_size);
+ unsigned char* buf = malloc(data_size);
if (buf == NULL) {
logger(LL_ERROR, "out of memory\n");
return NULL;
@@ -409,7 +409,7 @@ void* mbn_mav25_stitch(const void* data, size_t data_size, const void* blob, siz
}
if (sect_off + sect_size > data_size) {
- logger(LL_ERROR, "%s: section (0x%llx+0x%zx) is bigger than the data\n", __func__, sect_off, sect_size);
+ logger(LL_ERROR, "%s: section (0x%lx+0x%zx) is bigger than the data\n", __func__, (unsigned long)sect_off, sect_size);
return NULL;
}
@@ -442,8 +442,7 @@ void* mbn_mav25_stitch(const void* data, size_t data_size, const void* blob, siz
size_t new_oem_sig_and_cert_chain_size =
src_header->oem_signature_size + src_header->oem_certificate_chain_size;
off_t new_oem_sig_and_cert_chain_off = new_metadata_and_hash_table_size +
- header->qti_signature_size +
- header->qti_certificate_chain_size;
+ header->qti_signature_size + header->qti_certificate_chain_size;
if (new_metadata_and_hash_table_size > blob_size) {
logger(LL_ERROR, "%s: new metadata (0x%zx) and hash table (0x%x) are bigger than the source (0x%zx)\n", __func__, new_metadata_size, src_header->hash_table_size, blob_size);
@@ -465,16 +464,16 @@ void* mbn_mav25_stitch(const void* data, size_t data_size, const void* blob, siz
return NULL;
}
- void* buf = malloc(data_size);
+ unsigned char* buf = malloc(data_size);
if (buf == NULL) {
logger(LL_ERROR, "out of memory\n");
return NULL;
}
memcpy(buf, data, data_size);
- logger(LL_DEBUG, "%s: stitching mbn at 0x%llx (0x%zx bytes)\n", __func__, sect_off, new_metadata_and_hash_table_size);
+ logger(LL_DEBUG, "%s: stitching mbn at 0x%lx (0x%zx bytes)\n", __func__, (unsigned long)sect_off, new_metadata_and_hash_table_size);
memcpy(buf + sect_off, blob, new_metadata_and_hash_table_size);
- logger(LL_DEBUG, "%s: stitching mbn at 0x%llx (0x%zx bytes)\n", __func__, sect_off + new_oem_sig_and_cert_chain_off, new_oem_sig_and_cert_chain_size);
+ logger(LL_DEBUG, "%s: stitching mbn at 0x%lx (0x%zx bytes)\n", __func__, (unsigned long)(sect_off + new_oem_sig_and_cert_chain_off), new_oem_sig_and_cert_chain_size);
memcpy(buf + sect_off + new_oem_sig_and_cert_chain_off, blob + new_metadata_and_hash_table_size, new_oem_sig_and_cert_chain_size);
return buf;
diff --git a/src/restore.c b/src/restore.c
index f2fd9be..deeaf43 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -2016,8 +2016,6 @@ static int restore_sign_bbfw(const char* bbfwtmp, plist_t bbtss, const unsigned
goto leave;
}
}
- free(buffer);
- buffer = NULL;
blob_size = 0;
blob = (const unsigned char*)plist_get_data_ptr(node, &blob_size);
@@ -2043,17 +2041,21 @@ static int restore_sign_bbfw(const char* bbfwtmp, plist_t bbtss, const unsigned
fls = NULL;
} else if (bb_chip_id == 0x1F30E1) { // Mav25 - Qualcomm Snapdragon X80 5G Modem
fdata = mbn_mav25_stitch(buffer, zstat.size, blob, (size_t)blob_size);
+ fsize = zstat.size;
if (!fdata) {
logger(LL_ERROR, "Could not stitch %s\n", signfn);
goto leave;
}
} else {
fdata = mbn_stitch(buffer, zstat.size, blob, (size_t)blob_size);
+ fsize = zstat.size;
if (!fdata) {
logger(LL_ERROR, "Could not stitch %s\n", signfn);
goto leave;
}
}
+ free(buffer);
+ buffer = NULL;
zs = zip_source_buffer(za, fdata, fsize, 1);
if (!zs) {