summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-07-01 00:45:50 +0200
committerGravatar Nikias Bassen2025-07-01 00:45:50 +0200
commitc752e8780b043c8822be2417cc5596b8f2ad9c0b (patch)
treec57bae87f86c43d68a74447bad319433f66cb89a /src
parentc17f9d6b17daa6121ec1ef0284d701cd3d1387b2 (diff)
downloadidevicerestore-c752e8780b043c8822be2417cc5596b8f2ad9c0b.tar.gz
idevicerestore-c752e8780b043c8822be2417cc5596b8f2ad9c0b.tar.bz2
Update codebase to use (const) void* and size_t where applicable
Diffstat (limited to 'src')
-rw-r--r--src/ace3.c6
-rw-r--r--src/ace3.h2
-rw-r--r--src/asr.c4
-rw-r--r--src/asr.h2
-rw-r--r--src/dfu.c18
-rw-r--r--src/dfu.h4
-rw-r--r--src/download.c2
-rw-r--r--src/download.h2
-rw-r--r--src/fls.c12
-rw-r--r--src/fls.h8
-rw-r--r--src/ftab.c8
-rw-r--r--src/ftab.h8
-rw-r--r--src/idevicerestore.c32
-rw-r--r--src/idevicerestore.h4
-rw-r--r--src/img3.c4
-rw-r--r--src/img3.h16
-rw-r--r--src/img4.c2
-rw-r--r--src/img4.h2
-rw-r--r--src/ipsw.c42
-rw-r--r--src/ipsw.h4
-rw-r--r--src/log.c2
-rw-r--r--src/log.h2
-rw-r--r--src/mbn.c4
-rw-r--r--src/mbn.h4
-rw-r--r--src/recovery.c10
-rw-r--r--src/restore.c122
26 files changed, 158 insertions, 168 deletions
diff --git a/src/ace3.c b/src/ace3.c
index 9bbc8b6..d3da372 100644
--- a/src/ace3.c
+++ b/src/ace3.c
@@ -78,7 +78,7 @@ static int uarp_version_convert(uint32_t* version_data, uint32_t* version_out)
return 0;
}
-int ace3_create_binary(const unsigned char* uarp_fw, size_t uarp_size, uint64_t bdid, unsigned int prev, plist_t tss, unsigned char** bin_out, size_t* bin_size)
+int ace3_create_binary(const void* uarp_fw, size_t uarp_size, uint64_t bdid, unsigned int prev, plist_t tss, void** bin_out, size_t* bin_size)
{
struct ace3bin_header {
uint32_t magic; // 0xACE00003
@@ -220,7 +220,7 @@ int ace3_create_binary(const unsigned char* uarp_fw, size_t uarp_size, uint64_t
uint32_t toc_offset = be32toh(uarp_hdr->toc_offset);
uint32_t toc_size = be32toh(uarp_hdr->toc_size);
const unsigned char* p = uarp_fw + uarp_hdr_size;
- while (p < uarp_fw + toc_size) {
+ while (p < (const unsigned char*)uarp_fw + toc_size) {
struct uarp_toc_entry* entry = (struct uarp_toc_entry*)p;
uint32_t te_size = be32toh(entry->this_size);
if (strncmp((char*)&(entry->fourcc), payload_4cc, 4) == 0) {
@@ -244,7 +244,7 @@ int ace3_create_binary(const unsigned char* uarp_fw, size_t uarp_size, uint64_t
uint32_t content_size = data1_size + data2_size + im4m_size + dl_size;
- *bin_out = (unsigned char*)malloc(0x40 + content_size);
+ *bin_out = malloc(0x40 + content_size);
struct ace3bin_header* hdr = (struct ace3bin_header*)(*bin_out);
hdr->magic = htole32(0xACE00003);
hdr->version = htole32(data1_version);
diff --git a/src/ace3.h b/src/ace3.h
index 2ef65a7..6c93e1e 100644
--- a/src/ace3.h
+++ b/src/ace3.h
@@ -8,7 +8,7 @@ extern "C" {
#include <stdint.h>
#include <plist/plist.h>
-int ace3_create_binary(const unsigned char* uarp_fw, size_t uarp_size, uint64_t bdid, unsigned int prev, plist_t tss, unsigned char** bin_out, size_t* bin_size);
+int ace3_create_binary(const void* uarp_fw, size_t uarp_size, uint64_t bdid, unsigned int prev, plist_t tss, void** bin_out, size_t* bin_size);
#ifdef __cplusplus
}
diff --git a/src/asr.c b/src/asr.c
index fba59d9..e140980 100644
--- a/src/asr.c
+++ b/src/asr.c
@@ -175,14 +175,14 @@ int asr_send(asr_client_t asr, plist_t data)
return 0;
}
-int asr_send_buffer(asr_client_t asr, const char* data, uint32_t size)
+int asr_send_buffer(asr_client_t asr, const void* data, size_t size)
{
uint32_t bytes = 0;
idevice_error_t device_error = IDEVICE_E_SUCCESS;
device_error = idevice_connection_send(asr->connection, data, size, &bytes);
if (device_error != IDEVICE_E_SUCCESS || bytes != size) {
- logger(LL_ERROR, "Unable to send data to ASR. Sent %u of %u bytes.\n", bytes, size);
+ logger(LL_ERROR, "Unable to send data to ASR. Sent %u of %zu bytes.\n", bytes, size);
return -1;
}
diff --git a/src/asr.h b/src/asr.h
index 4473fbb..52e8d75 100644
--- a/src/asr.h
+++ b/src/asr.h
@@ -50,7 +50,7 @@ int asr_open_with_timeout(idevice_t device, asr_client_t* asr, uint16_t port);
void asr_set_progress_callback(asr_client_t asr, asr_progress_cb_t, void* userdata);
int asr_send(asr_client_t asr, plist_t data);
int asr_receive(asr_client_t asr, plist_t* data);
-int asr_send_buffer(asr_client_t asr, const char* data, uint32_t size);
+int asr_send_buffer(asr_client_t asr, const void* data, size_t size);
void asr_free(asr_client_t asr);
int asr_perform_validation(asr_client_t asr, ipsw_file_handle_t file);
int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file);
diff --git a/src/dfu.c b/src/dfu.c
index 83046b9..4650e9a 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -105,13 +105,13 @@ irecv_device_t dfu_get_irecv_device(struct idevicerestore_client_t* client)
return device;
}
-int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size, unsigned int irecv_options)
+int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, const void* buffer, size_t size, unsigned int irecv_options)
{
irecv_error_t err = 0;
- logger(LL_INFO, "Sending data (%d bytes)...\n", size);
+ logger(LL_INFO, "Sending data (%zu bytes)...\n", size);
- err = irecv_send_buffer(client->dfu->client, buffer, size, irecv_options);
+ err = irecv_send_buffer(client->dfu->client, (unsigned char*)buffer, size, irecv_options);
if (err != IRECV_E_SUCCESS) {
logger(LL_ERROR, "Unable to send data: %s\n", irecv_strerror(err));
return -1;
@@ -120,7 +120,7 @@ int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, unsigne
return 0;
}
-int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size)
+int dfu_send_buffer(struct idevicerestore_client_t* client, const void* buffer, size_t size)
{
return dfu_send_buffer_with_options(client, buffer, size, IRECV_SEND_OPT_DFU_NOTIFY_FINISH);
}
@@ -135,8 +135,8 @@ int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_ide
tss = client->tss_localpolicy;
}
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
if (strcmp(component, "Ap,LocalPolicy") == 0) {
// If Ap,LocalPolicy => Inject an empty policy
@@ -166,8 +166,8 @@ int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_ide
path = NULL;
}
- unsigned char* data = NULL;
- uint32_t size = 0;
+ void* data = NULL;
+ size_t size = 0;
if (personalize_component(client, component, component_data, component_size, tss, &data, &size) < 0) {
logger(LL_ERROR, "Unable to get personalized component: %s\n", component);
@@ -198,7 +198,7 @@ int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_ide
size += fillsize;
}
- logger(LL_INFO, "Sending %s (%d bytes)...\n", component, size);
+ logger(LL_INFO, "Sending %s (%zu bytes)...\n", component, size);
irecv_error_t err = irecv_send_buffer(client->dfu->client, data, size, IRECV_SEND_OPT_DFU_NOTIFY_FINISH);
if (err != IRECV_E_SUCCESS) {
diff --git a/src/dfu.h b/src/dfu.h
index 4590dbd..7b1d092 100644
--- a/src/dfu.h
+++ b/src/dfu.h
@@ -40,8 +40,8 @@ struct dfu_client_t {
int dfu_client_new(struct idevicerestore_client_t* client);
void dfu_client_free(struct idevicerestore_client_t* client);
irecv_device_t dfu_get_irecv_device(struct idevicerestore_client_t* client);
-int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size);
-int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size, unsigned int irecv_options);
+int dfu_send_buffer(struct idevicerestore_client_t* client, const void* buffer, size_t size);
+int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, const void* buffer, size_t size, unsigned int irecv_options);
int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component);
int dfu_get_bdid(struct idevicerestore_client_t* client, unsigned int* bdid);
int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid);
diff --git a/src/download.c b/src/download.c
index 2f3a836..0b6b076 100644
--- a/src/download.c
+++ b/src/download.c
@@ -43,7 +43,7 @@ static size_t download_write_buffer_callback(char* data, size_t size, size_t nme
return total;
}
-int download_to_buffer(const char* url, char** buf, uint32_t* length)
+int download_to_buffer(const char* url, void** buf, size_t* length)
{
int res = 0;
CURL* handle = curl_easy_init();
diff --git a/src/download.h b/src/download.h
index 1edde5b..bbb5aa0 100644
--- a/src/download.h
+++ b/src/download.h
@@ -28,7 +28,7 @@ extern "C" {
#include <stdint.h>
-int download_to_buffer(const char* url, char** buf, uint32_t* length);
+int download_to_buffer(const char* url, void** buf, size_t* length);
int download_to_file(const char* url, const char* filename, int enable_progress);
#ifdef __cplusplus
diff --git a/src/fls.c b/src/fls.c
index cc75c54..8b747a9 100644
--- a/src/fls.c
+++ b/src/fls.c
@@ -101,7 +101,7 @@ static void fls_parse_elements(fls_file* fls)
}
}
-fls_file* fls_parse(unsigned char* data, unsigned int size)
+fls_file* fls_parse(const void* data, size_t size)
{
fls_file* fls = (fls_file*)malloc(sizeof(fls_file));
if (!fls) {
@@ -132,7 +132,7 @@ void fls_free(fls_file* fls)
}
}
-int fls_update_sig_blob(fls_file* fls, const unsigned char* sigdata, unsigned int siglen)
+int fls_update_sig_blob(fls_file* fls, const void* sigdata, size_t siglen)
{
/* FIXME: the code in this function is not big endian safe */
if (!fls || !fls->num_elements) {
@@ -155,8 +155,8 @@ int fls_update_sig_blob(fls_file* fls, const unsigned char* sigdata, unsigned in
return -1;
}
- uint32_t oldsiglen = datasize - sigoffset;
- uint32_t newsize = fls->size - oldsiglen + siglen;
+ size_t oldsiglen = datasize - sigoffset;
+ size_t newsize = fls->size - oldsiglen + siglen;
unsigned int i;
uint32_t offset = 0;
@@ -239,7 +239,7 @@ int fls_update_sig_blob(fls_file* fls, const unsigned char* sigdata, unsigned in
return 0;
}
-int fls_insert_ticket(fls_file* fls, const unsigned char* data, unsigned int size)
+int fls_insert_ticket(fls_file* fls, const void* data, size_t size)
{
/* FIXME: the code in this function is not big endian safe */
if (!fls || !fls->num_elements) {
@@ -255,7 +255,7 @@ int fls_insert_ticket(fls_file* fls, const unsigned char* data, unsigned int siz
if (size%4 != 0) {
padding = 4-(size%4);
}
- uint32_t newsize = fls->size + size + padding;
+ size_t newsize = fls->size + size + padding;
unsigned int i;
uint32_t offset = 0;
void* newdata = malloc(newsize);
diff --git a/src/fls.h b/src/fls.h
index 57b3869..2db9029 100644
--- a/src/fls.h
+++ b/src/fls.h
@@ -74,12 +74,12 @@ typedef struct {
fls_element** elements;
const fls_0c_element* c_element;
void* data;
- uint32_t size;
+ size_t size;
} fls_file;
-fls_file* fls_parse(unsigned char* data, unsigned int size);
+fls_file* fls_parse(const void* data, size_t size);
void fls_free(fls_file* fls);
-int fls_update_sig_blob(fls_file* fls, const unsigned char* data, unsigned int size);
-int fls_insert_ticket(fls_file* fls, const unsigned char* data, unsigned int size);
+int fls_update_sig_blob(fls_file* fls, const void* data, size_t size);
+int fls_insert_ticket(fls_file* fls, const void* data, size_t size);
#endif
diff --git a/src/ftab.c b/src/ftab.c
index cc74251..d0fc26b 100644
--- a/src/ftab.c
+++ b/src/ftab.c
@@ -28,7 +28,7 @@
#include "common.h"
#include "endianness.h"
-int ftab_parse(unsigned char *data, unsigned int data_size, ftab_t *ftab, uint32_t *tag)
+int ftab_parse(const void *data, size_t data_size, ftab_t *ftab, uint32_t *tag)
{
if (!data || !data_size || !ftab) {
return -1;
@@ -81,7 +81,7 @@ int ftab_parse(unsigned char *data, unsigned int data_size, ftab_t *ftab, uint32
return 0;
}
-int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, unsigned char **data, unsigned int *data_size)
+int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, void **data, size_t *data_size)
{
if (!ftab || !tag || !data || !data_size) {
return -1;
@@ -99,7 +99,7 @@ int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, unsigned char **data, unsigned
return res;
}
-int ftab_add_entry(ftab_t ftab, uint32_t tag, unsigned char *data, unsigned int data_size)
+int ftab_add_entry(ftab_t ftab, uint32_t tag, const void *data, size_t data_size)
{
if (!ftab || !tag || !data || !data_size) {
return -1;
@@ -140,7 +140,7 @@ int ftab_add_entry(ftab_t ftab, uint32_t tag, unsigned char *data, unsigned int
return 0;
}
-int ftab_write(ftab_t ftab, unsigned char **data, unsigned int *data_size)
+int ftab_write(ftab_t ftab, void **data, size_t *data_size)
{
uint32_t i;
unsigned int total_size = sizeof(struct ftab_header);
diff --git a/src/ftab.h b/src/ftab.h
index a6ec6a4..d5d4d92 100644
--- a/src/ftab.h
+++ b/src/ftab.h
@@ -58,10 +58,10 @@ struct ftab_fmt {
typedef struct ftab_fmt *ftab_t;
-int ftab_parse(unsigned char *data, unsigned int data_size, ftab_t *ftab, uint32_t *tag);
-int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, unsigned char **data, unsigned int *data_size);
-int ftab_add_entry(ftab_t ftab, uint32_t tag, unsigned char *data, unsigned int data_size);
-int ftab_write(ftab_t ftab, unsigned char **data, unsigned int *data_size);
+int ftab_parse(const void *data, size_t data_size, ftab_t *ftab, uint32_t *tag);
+int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, void **data, size_t *data_size);
+int ftab_add_entry(ftab_t ftab, uint32_t tag, const void *data, size_t data_size);
+int ftab_write(ftab_t ftab, void **data, size_t *data_size);
int ftab_free(ftab_t ftab);
#ifdef __cplusplus
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index f4ced47..7be50ea 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -419,8 +419,8 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
char wtfname[256];
snprintf(wtfname, sizeof(wtfname), "Firmware/dfu/WTF.s5l%04xxall.RELEASE.dfu", cpid);
- unsigned char* wtftmp = NULL;
- unsigned int wtfsize = 0;
+ void* wtftmp = NULL;
+ size_t wtfsize = 0;
// Prefer to get WTF file from the restore IPSW
ipsw_extract_to_memory(client->ipsw, wtfname, &wtftmp, &wtfsize);
@@ -773,8 +773,8 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
logger(LL_ERROR, "Unable to get path of USBPortController1,USBFirmware component\n");
return -1;
}
- unsigned char* uarp_buf = NULL;
- unsigned int uarp_size = 0;
+ void* uarp_buf = NULL;
+ size_t uarp_size = 0;
if (ipsw_extract_to_memory(client->ipsw, fwpath, &uarp_buf, &uarp_size) < 0) {
plist_free(parameters);
logger(LL_ERROR, "Unable to extract '%s' from IPSW\n", fwpath);
@@ -804,7 +804,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
logger(LL_INFO, "Received USBPortController1,Ticket\n");
logger(LL_INFO, "Creating Ace3Binary\n");
- unsigned char* ace3bin = NULL;
+ void* ace3bin = NULL;
size_t ace3bin_size = 0;
if (ace3_create_binary(uarp_buf, uarp_size, pdfu_bdid, prev, response, &ace3bin, &ace3bin_size) < 0) {
logger(LL_ERROR, "Could not create Ace3Binary\n");
@@ -814,7 +814,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
free(uarp_buf);
if (idevicerestore_keep_pers) {
- write_file("Ace3Binary", (const char*)ace3bin, ace3bin_size);
+ write_file("Ace3Binary", ace3bin, ace3bin_size);
}
if (dfu_send_buffer_with_options(client, ace3bin, ace3bin_size, IRECV_SEND_OPT_DFU_NOTIFY_FINISH | IRECV_SEND_OPT_DFU_SMALL_PKT) < 0) {
@@ -898,9 +898,9 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
// get all_flash file manifest
char *files[16];
- char *fmanifest = NULL;
- uint32_t msize = 0;
- if (ipsw_extract_to_memory(client->ipsw, tmpstr, (unsigned char**)&fmanifest, &msize) < 0) {
+ void *fmanifest = NULL;
+ size_t msize = 0;
+ if (ipsw_extract_to_memory(client->ipsw, tmpstr, &fmanifest, &msize) < 0) {
logger(LL_ERROR, "could not extract %s from IPSW\n", tmpstr);
free(build_identity);
return -1;
@@ -2809,7 +2809,7 @@ int build_manifest_get_identity_count(plist_t build_manifest)
return plist_array_get_size(build_identities_array);
}
-int extract_component(ipsw_archive_t ipsw, const char* path, unsigned char** component_data, unsigned int* component_size)
+int extract_component(ipsw_archive_t ipsw, const char* path, void** component_data, size_t* component_size)
{
char* component_name = NULL;
if (!ipsw || !path || !component_data || !component_size) {
@@ -2831,19 +2831,19 @@ int extract_component(ipsw_archive_t ipsw, const char* path, unsigned char** com
return 0;
}
-int personalize_component(struct idevicerestore_client_t* client, const char *component_name, const unsigned char* component_data, unsigned int component_size, plist_t tss_response, unsigned char** personalized_component, unsigned int* personalized_component_size)
+int personalize_component(struct idevicerestore_client_t* client, const char *component_name, const void* component_data, size_t component_size, plist_t tss_response, void** personalized_component, size_t* personalized_component_size)
{
- unsigned char* component_blob = NULL;
- unsigned int component_blob_size = 0;
- unsigned char* stitched_component = NULL;
- unsigned int stitched_component_size = 0;
+ void* component_blob = NULL;
+ size_t component_blob_size = 0;
+ void* stitched_component = NULL;
+ size_t stitched_component_size = 0;
if (tss_response && plist_dict_get_item(tss_response, "ApImg4Ticket")) {
/* stitch ApImg4Ticket into IMG4 file */
img4_stitch_component(component_name, component_data, component_size, client->parameters, tss_response, &stitched_component, &stitched_component_size);
} else {
/* try to get blob for current component from tss response */
- if (tss_response && tss_response_get_blob_by_entry(tss_response, component_name, &component_blob) < 0) {
+ if (tss_response && tss_response_get_blob_by_entry(tss_response, component_name, (unsigned char**)&component_blob) < 0) {
logger(LL_DEBUG, "NOTE: No SHSH blob found for component %s\n", component_name);
}
diff --git a/src/idevicerestore.h b/src/idevicerestore.h
index 1e01672..9d6f5af 100644
--- a/src/idevicerestore.h
+++ b/src/idevicerestore.h
@@ -112,8 +112,8 @@ void build_identity_print_information(plist_t build_identity);
int build_identity_has_component(plist_t build_identity, const char* component);
int build_identity_get_component_path(plist_t build_identity, const char* component, char** path);
int ipsw_extract_filesystem(ipsw_archive_t ipsw, plist_t build_identity, char** filesystem);
-int extract_component(ipsw_archive_t ipsw, const char* path, unsigned char** component_data, unsigned int* component_size);
-int personalize_component(struct idevicerestore_client_t* client, const char *component, const unsigned char* component_data, unsigned int component_size, plist_t tss_response, unsigned char** personalized_component, unsigned int* personalized_component_size);
+int extract_component(ipsw_archive_t ipsw, const char* path, void** component_data, size_t* component_size);
+int personalize_component(struct idevicerestore_client_t* client, const char *component, const void* component_data, size_t component_size, plist_t tss_response, void** personalized_component, size_t* personalized_component_size);
int get_preboard_manifest(struct idevicerestore_client_t* client, plist_t build_identity, plist_t* manifest);
const char* get_component_name(const char* filename);
diff --git a/src/img3.c b/src/img3.c
index a700839..db50703 100644
--- a/src/img3.c
+++ b/src/img3.c
@@ -402,7 +402,7 @@ static int img3_get_data(img3_file* image, unsigned char** pdata, unsigned int*
return 0;
}
-int img3_stitch_component(const char* component_name, const unsigned char* component_data, unsigned int component_size, const unsigned char* blob, unsigned int blob_size, unsigned char** img3_data, unsigned int *img3_size)
+int img3_stitch_component(const char* component_name, const void* component_data, size_t component_size, const void* blob, size_t blob_size, void** img3_data, size_t *img3_size)
{
img3_file *img3 = NULL;
unsigned char* outbuf = NULL;
@@ -422,7 +422,7 @@ int img3_stitch_component(const char* component_name, const unsigned char* compo
}
if (((img3_element_header*)blob)->full_size != blob_size) {
- logger(LL_ERROR, "Invalid blob passed for %s IMG3: The size %d embedded in the blob does not match the passed size of %d\n", component_name, ((img3_element_header*)blob)->full_size, blob_size);
+ logger(LL_ERROR, "Invalid blob passed for %s IMG3: The size %d embedded in the blob does not match the passed size of %zu\n", component_name, ((img3_element_header*)blob)->full_size, blob_size);
img3_free(img3);
return -1;
}
diff --git a/src/img3.h b/src/img3.h
index 20d9248..b8e30e9 100644
--- a/src/img3.h
+++ b/src/img3.h
@@ -79,23 +79,9 @@ typedef struct {
int idx_ecid_element;
int idx_shsh_element;
int idx_cert_element;
-/* img3_element* type_element;
- img3_element* data_element;
- img3_element* vers_element;
- img3_element* sepo_element;
- img3_element* bord_element;
- img3_element* sepo2_element;
- img3_element* chip_element;
- img3_element* bord2_element;
- img3_element* kbag1_element;
- img3_element* kbag2_element;
- img3_element* ecid_element;
- img3_element* shsh_element;
- img3_element* cert_element;
- img3_element* unkn_element;*/
} img3_file;
-int img3_stitch_component(const char* component_name, const unsigned char* component_data, unsigned int component_size, const unsigned char* blob, unsigned int blob_size, unsigned char** img3_data, unsigned int *img3_size);
+int img3_stitch_component(const char* component_name, const void* component_data, size_t component_size, const void* blob, size_t blob_size, void** img3_data, size_t *img3_size);
#ifdef __cplusplus
}
diff --git a/src/img4.c b/src/img4.c
index b23775a..e58dd26 100644
--- a/src/img4.c
+++ b/src/img4.c
@@ -396,7 +396,7 @@ static const char *_img4_get_component_tag(const char *compname)
return NULL;
}
-int img4_stitch_component(const char* component_name, const unsigned char* component_data, unsigned int component_size, plist_t parameters, plist_t tss_response, unsigned char** img4_data, unsigned int *img4_size)
+int img4_stitch_component(const char* component_name, const void* component_data, size_t component_size, plist_t parameters, plist_t tss_response, void** img4_data, size_t *img4_size)
{
unsigned char* magic_header = NULL;
unsigned int magic_header_size = 0;
diff --git a/src/img4.h b/src/img4.h
index 19c1c84..1c5ef36 100644
--- a/src/img4.h
+++ b/src/img4.h
@@ -26,7 +26,7 @@
extern "C" {
#endif
-int img4_stitch_component(const char* component_name, const unsigned char* component_data, unsigned int component_size, plist_t parameters, plist_t tss_response, unsigned char** img4_data, unsigned int *img4_size);
+int img4_stitch_component(const char* component_name, const void* component_data, size_t component_size, plist_t parameters, plist_t tss_response, void** img4_data, size_t *img4_size);
int img4_create_local_manifest(plist_t request, plist_t build_identity, plist_t* manifest);
#ifdef __cplusplus
diff --git a/src/ipsw.c b/src/ipsw.c
index 201f9cd..cebfa49 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -98,13 +98,13 @@ int ipsw_print_info(const char* path)
}
fclose(f);
- char* plist_buf = NULL;
+ void* plist_buf = NULL;
uint32_t plist_len = 0;
if (memcmp(&magic, "PK\x03\x04", 4) == 0) {
ipsw_archive_t ipsw = ipsw_open(thepath);
- unsigned int rlen = 0;
- if (ipsw_extract_to_memory(ipsw, "BuildManifest.plist", (unsigned char**)&plist_buf, &rlen) < 0) {
+ size_t rlen = 0;
+ if (ipsw_extract_to_memory(ipsw, "BuildManifest.plist", &plist_buf, &rlen) < 0) {
ipsw_close(ipsw);
logger(LL_ERROR, "Failed to extract BuildManifest.plist from IPSW!\n");
return -1;
@@ -113,7 +113,7 @@ int ipsw_print_info(const char* path)
plist_len = (uint32_t)rlen;
} else {
size_t rlen = 0;
- if (read_file(thepath, (void**)&plist_buf, &rlen) < 0) {
+ if (read_file(thepath, &plist_buf, &rlen) < 0) {
logger(LL_ERROR, "Failed to read BuildManifest.plist!\n");
return -1;
}
@@ -623,7 +623,7 @@ int ipsw_file_exists(ipsw_archive_t ipsw, const char* infile)
return 1;
}
-int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, unsigned char** pbuffer, unsigned int* psize)
+int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, void** pbuffer, size_t* psize)
{
size_t size = 0;
unsigned char* buffer = NULL;
@@ -666,6 +666,13 @@ int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, unsigned cha
}
size = zstat.size;
+ if ((uint64_t)size != (uint64_t)zstat.size) {
+ logger(LL_ERROR, "Not enough memory to allocate a buffer of size %" PRIu64 "\n", (uint64_t)zstat.size);
+ zip_fclose(zfile);
+ zip_unchange_all(zip);
+ zip_close(zip);
+ return -1;
+ }
buffer = (unsigned char*) malloc(size+1);
if (buffer == NULL) {
logger(LL_ERROR, "Out of memory\n");
@@ -687,7 +694,7 @@ int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, unsigned cha
free(buffer);
return -1;
} else if (zr != size) {
- logger(LL_ERROR, "zip_fread: %s got only %lld of %zu\n", infile, zr, size);
+ logger(LL_ERROR, "zip_fread: %s got only %zu of %zu\n", infile, (size_t)zr, size);
free(buffer);
return -1;
}
@@ -706,6 +713,11 @@ int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, unsigned cha
return -1;
}
size = fst.st_size;
+ if ((uint64_t)size != (uint64_t)fst.st_size) {
+ logger(LL_ERROR, "Not enough memory to allocate a buffer of size %" PRIu64 "\n", (uint64_t)fst.st_size);
+ free(filepath);
+ return -1;
+ }
buffer = (unsigned char*)malloc(size+1);
if (buffer == NULL) {
logger(LL_ERROR, "Out of memory\n");
@@ -901,15 +913,15 @@ int ipsw_extract_send(ipsw_archive_t ipsw, const char* infile, int blocksize, ip
int ipsw_extract_build_manifest(ipsw_archive_t ipsw, plist_t* buildmanifest, int *tss_enabled)
{
- unsigned int size = 0;
- unsigned char* data = NULL;
+ size_t size = 0;
+ void* data = NULL;
*tss_enabled = 0;
/* older devices don't require personalized firmwares and use a BuildManifesto.plist */
if (ipsw_file_exists(ipsw, "BuildManifesto.plist")) {
if (ipsw_extract_to_memory(ipsw, "BuildManifesto.plist", &data, &size) == 0) {
- plist_from_xml((char*)data, size, buildmanifest);
+ plist_from_memory((char*)data, size, buildmanifest, NULL);
free(data);
return 0;
}
@@ -921,7 +933,7 @@ int ipsw_extract_build_manifest(ipsw_archive_t ipsw, plist_t* buildmanifest, int
/* whereas newer devices do not require personalized firmwares and use a BuildManifest.plist */
if (ipsw_extract_to_memory(ipsw, "BuildManifest.plist", &data, &size) == 0) {
*tss_enabled = 1;
- plist_from_xml((char*)data, size, buildmanifest);
+ plist_from_memory((char*)data, size, buildmanifest, NULL);
free(data);
return 0;
}
@@ -931,11 +943,11 @@ int ipsw_extract_build_manifest(ipsw_archive_t ipsw, plist_t* buildmanifest, int
int ipsw_extract_restore_plist(ipsw_archive_t ipsw, plist_t* restore_plist)
{
- unsigned int size = 0;
- unsigned char* data = NULL;
+ size_t size = 0;
+ void* data = NULL;
if (ipsw_extract_to_memory(ipsw, "Restore.plist", &data, &size) == 0) {
- plist_from_xml((char*)data, size, restore_plist);
+ plist_from_memory((char*)data, size, restore_plist, NULL);
free(data);
return 0;
}
@@ -1073,7 +1085,7 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
{
char url[256];
char *jdata = NULL;
- uint32_t jsize = 0;
+ size_t jsize = 0;
plist_t dict = NULL;
plist_t node = NULL;
plist_t fws = NULL;
@@ -1088,7 +1100,7 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
*firmwares = NULL;
snprintf(url, sizeof(url), "https://api.ipsw.me/v4/device/%s", product);
- if (download_to_buffer(url, &jdata, &jsize) < 0) {
+ if (download_to_buffer(url, (void**)&jdata, &jsize) < 0) {
logger(LL_ERROR, "Download from %s failed.\n", url);
return -1;
}
diff --git a/src/ipsw.h b/src/ipsw.h
index 8cb2561..b22e614 100644
--- a/src/ipsw.h
+++ b/src/ipsw.h
@@ -44,7 +44,7 @@ void ipsw_close(ipsw_archive_t ipsw);
int ipsw_print_info(const char* ipsw);
typedef int (*ipsw_list_cb)(void *ctx, ipsw_archive_t ipsw, const char *name, struct stat *stat);
-typedef int (*ipsw_send_cb)(void *ctx, void *data, size_t size, size_t done, size_t total_size);
+typedef int (*ipsw_send_cb)(void *ctx, const void *data, size_t size, size_t done, size_t total_size);
struct ipsw_file_handle {
FILE* file;
@@ -69,7 +69,7 @@ int ipsw_file_exists(ipsw_archive_t ipsw, const char* infile);
int ipsw_get_file_size(ipsw_archive_t ipsw, const char* infile, uint64_t* size);
int ipsw_extract_to_file(ipsw_archive_t ipsw, const char* infile, const char* outfile);
int ipsw_extract_to_file_with_progress(ipsw_archive_t ipsw, const char* infile, const char* outfile, int print_progress);
-int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, unsigned char** pbuffer, unsigned int* psize);
+int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, void** pbuffer, size_t* psize);
int ipsw_extract_send(ipsw_archive_t ipsw, const char* infile, int blocksize, ipsw_send_cb send_callback, void* ctx);
int ipsw_extract_build_manifest(ipsw_archive_t ipsw, plist_t* buildmanifest, int *tss_enabled);
int ipsw_extract_restore_plist(ipsw_archive_t ipsw, plist_t* restore_plist);
diff --git a/src/log.c b/src/log.c
index 515bea1..5a0ff94 100644
--- a/src/log.c
+++ b/src/log.c
@@ -166,7 +166,7 @@ static void print_funcf(enum loglevel level, const char* fmt, ...)
va_end(ap);
}
-void logger_dump_hex(enum loglevel level, const void* buf, unsigned int len)
+void logger_dump_hex(enum loglevel level, const void* buf, size_t len)
{
char *fs;
diff --git a/src/log.h b/src/log.h
index ad3da14..2563af3 100644
--- a/src/log.h
+++ b/src/log.h
@@ -37,7 +37,7 @@ typedef void (*logger_print_func)(enum loglevel level, const char*, va_list);
void logger(enum loglevel level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
int logger_set_logfile(const char* path);
void logger_set_print_func(logger_print_func func);
-void logger_dump_hex(enum loglevel level, const void* buf, unsigned int len);
+void logger_dump_hex(enum loglevel level, const void* buf, size_t len);
void logger_dump_plist(enum loglevel level, plist_t plist, int human_readable);
#endif
diff --git a/src/mbn.c b/src/mbn.c
index b7d3527..409d9eb 100644
--- a/src/mbn.c
+++ b/src/mbn.c
@@ -25,7 +25,7 @@
#include "mbn.h"
#include "common.h"
-mbn_file* mbn_parse(unsigned char* data, unsigned int size)
+mbn_file* mbn_parse(const void* data, size_t size)
{
mbn_file* mbn = (mbn_file*)malloc(sizeof(mbn_file));
if (!mbn) {
@@ -72,7 +72,7 @@ void mbn_free(mbn_file* mbn)
}
}
-int mbn_update_sig_blob(mbn_file* mbn, const unsigned char* sigdata, unsigned int siglen)
+int mbn_update_sig_blob(mbn_file* mbn, const void* sigdata, size_t siglen)
{
if (!mbn) {
logger(LL_ERROR, "%s: no data\n", __func__);
diff --git a/src/mbn.h b/src/mbn.h
index 008ba61..a328128 100644
--- a/src/mbn.h
+++ b/src/mbn.h
@@ -100,8 +100,8 @@ typedef struct {
uint32_t size;
} mbn_file;
-mbn_file* mbn_parse(unsigned char* data, unsigned int size);
+mbn_file* mbn_parse(const void* data, size_t size);
void mbn_free(mbn_file* mbn);
-int mbn_update_sig_blob(mbn_file* mbn, const unsigned char* data, unsigned int size);
+int mbn_update_sig_blob(mbn_file* mbn, const void* data, size_t size);
#endif
diff --git a/src/recovery.c b/src/recovery.c
index 3c0027f..ccea423 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -280,8 +280,8 @@ int recovery_send_ticket(struct idevicerestore_client_t* client)
int recovery_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component)
{
- unsigned int size = 0;
- unsigned char* data = NULL;
+ size_t size = 0;
+ void* data = NULL;
char* path = NULL;
irecv_error_t err = 0;
@@ -298,8 +298,8 @@ int recovery_send_component(struct idevicerestore_client_t* client, plist_t buil
}
}
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, path, &component_data, &component_size);
free(path);
if (ret < 0) {
@@ -314,7 +314,7 @@ int recovery_send_component(struct idevicerestore_client_t* client, plist_t buil
return -1;
}
- logger(LL_INFO, "Sending %s (%d bytes)...\n", component, size);
+ logger(LL_INFO, "Sending %s (%zu bytes)...\n", component, size);
// FIXME: Did I do this right????
err = irecv_send_buffer(client->recovery->client, data, size, 0);
diff --git a/src/restore.c b/src/restore.c
index 3129176..bb4bbb5 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -1246,7 +1246,7 @@ static size_t _curl_header_callback(char* buffer, size_t size, size_t nitems, vo
strncpy(key, buffer, i);
key[i] = '\0';
i++;
- while (i < len && buffer[i] == ' ' || buffer[i] == '\t') i++;
+ while (i < len && (buffer[i] == ' ' || buffer[i] == '\t')) i++;
val = malloc(len-i+1);
strncpy(val, buffer+i, len-i);
val[len-i] = '\0';
@@ -1456,8 +1456,8 @@ int restore_send_streamed_image_decryption_key(struct idevicerestore_client_t* c
int restore_send_component(struct idevicerestore_client_t* client, plist_t message, const char* component, const char* component_name)
{
- unsigned int size = 0;
- unsigned char* data = NULL;
+ size_t size = 0;
+ void* data = NULL;
char* path = NULL;
plist_t blob = NULL;
plist_t dict = NULL;
@@ -1486,8 +1486,8 @@ int restore_send_component(struct idevicerestore_client_t* client, plist_t messa
}
}
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, path, &component_data, &component_size);
free(path);
path = NULL;
@@ -1538,14 +1538,14 @@ int restore_send_nor(struct idevicerestore_client_t* client, plist_t message)
char* restore_sep_path = NULL;
char firmware_path[PATH_MAX - 9];
char manifest_file[PATH_MAX];
- unsigned int manifest_size = 0;
- unsigned char* manifest_data = NULL;
+ size_t manifest_size = 0;
+ void* manifest_data = NULL;
char firmware_filename[PATH_MAX];
- unsigned int llb_size = 0;
- unsigned char* llb_data = NULL;
+ size_t llb_size = 0;
+ void* llb_data = NULL;
plist_t dict = NULL;
- unsigned int nor_size = 0;
- unsigned char* nor_data = NULL;
+ size_t nor_size = 0;
+ void* nor_data = NULL;
plist_t norimage = NULL;
plist_t firmware_files = NULL;
int flash_version_1 = 0;
@@ -1659,8 +1659,8 @@ int restore_send_nor(struct idevicerestore_client_t* client, plist_t message)
}
const char* component = "LLB";
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, llb_path, &component_data, &component_size);
free(llb_path);
if (ret < 0) {
@@ -1713,7 +1713,7 @@ int restore_send_nor(struct idevicerestore_client_t* client, plist_t message)
}
component_data = NULL;
- unsigned int component_size = 0;
+ component_size = 0;
if (extract_component(client->ipsw, comppath, &component_data, &component_size) < 0) {
free(iter);
@@ -1758,8 +1758,8 @@ int restore_send_nor(struct idevicerestore_client_t* client, plist_t message)
plist_free(firmware_files);
plist_dict_set_item(dict, "NorImageData", norimage);
- unsigned char* personalized_data = NULL;
- unsigned int personalized_size = 0;
+ void* personalized_data = NULL;
+ size_t personalized_size = 0;
if (build_identity_has_component(client->restore->build_identity, "RestoreSEP") &&
build_identity_get_component_path(client->restore->build_identity, "RestoreSEP", &restore_sep_path) == 0) {
@@ -2502,10 +2502,10 @@ static int restore_send_image_data(struct idevicerestore_client_t *client, plist
plist_array_append_item(matched_images, plist_new_string(component));
} else if (!image_name || !strcmp(image_name, component)) {
char *path = NULL;
- unsigned char* data = NULL;
- unsigned int size = 0;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* data = NULL;
+ size_t size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = -1;
if (!image_name) {
@@ -2616,8 +2616,8 @@ static plist_t restore_get_se_firmware_data(struct idevicerestore_client_t* clie
{
const char *comp_name = NULL;
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
plist_t parameters = NULL;
plist_t request = NULL;
plist_t response = NULL;
@@ -2730,9 +2730,9 @@ static plist_t restore_get_savage_firmware_data(struct idevicerestore_client_t*
{
char *comp_name = NULL;
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
- unsigned char* component_data_tmp = NULL;
+ void* component_data = NULL;
+ size_t component_size = 0;
+ void* component_data_tmp = NULL;
plist_t parameters = NULL;
plist_t request = NULL;
plist_t response = NULL;
@@ -2841,8 +2841,8 @@ static plist_t restore_get_yonkers_firmware_data(struct idevicerestore_client_t*
{
char *comp_name = NULL;
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
plist_t parameters = NULL;
plist_t request = NULL;
plist_t response = NULL;
@@ -2943,8 +2943,8 @@ static plist_t restore_get_rose_firmware_data(struct idevicerestore_client_t* cl
{
char *comp_name = NULL;
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
ftab_t ftab = NULL;
ftab_t rftab = NULL;
uint32_t ftag = 0;
@@ -3099,8 +3099,8 @@ static plist_t restore_get_veridian_firmware_data(struct idevicerestore_client_t
{
char *comp_name = "BMU,FirmwareMap";
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
plist_t parameters = NULL;
plist_t request = NULL;
plist_t response = NULL;
@@ -3271,8 +3271,8 @@ static plist_t restore_get_tcon_firmware_data(struct idevicerestore_client_t* cl
{
char *comp_name = "Baobab,TCON";
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
plist_t parameters = NULL;
plist_t request = NULL;
plist_t response = NULL;
@@ -3359,8 +3359,8 @@ static plist_t restore_get_timer_firmware_data(struct idevicerestore_client_t* c
{
char comp_name[64];
char *comp_path = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
ftab_t ftab = NULL;
ftab_t rftab = NULL;
uint32_t ftag = 0;
@@ -3976,13 +3976,13 @@ static int restore_bootability_send_one(void *ctx, ipsw_archive_t ipsw, const ch
logger(LL_DEBUG, "BootabilityBundle send m=%07o s=%10ld %s\n", stat->st_mode, (long)stat->st_size, subpath);
- unsigned char *buf = NULL;
- unsigned int size = 0;
+ void *buf = NULL;
+ size_t size = 0;
if ((S_ISLNK(stat->st_mode) || S_ISREG(stat->st_mode)) && stat->st_size != 0) {
ipsw_extract_to_memory(ipsw, name, &buf, &size);
if (size != stat->st_size) {
- logger(LL_ERROR, "expected %ld bytes but got %d for file %s\n", (long)stat->st_size, size, name);
+ logger(LL_ERROR, "expected %zu bytes but got %zu for file %s\n", (size_t)stat->st_size, size, name);
free(buf);
return -1;
}
@@ -4134,7 +4134,7 @@ static char* extract_global_manifest_path(plist_t build_identity, char *variant)
return ticket_path;
}
-int extract_global_manifest(struct idevicerestore_client_t* client, plist_t build_identity, char *variant, unsigned char** pbuffer, unsigned int* psize)
+int extract_global_manifest(struct idevicerestore_client_t* client, plist_t build_identity, char *variant, void** pbuffer, size_t* psize)
{
char* ticket_path = extract_global_manifest_path(build_identity, variant);
if (!ticket_path) {
@@ -4159,7 +4159,7 @@ struct _restore_send_file_data_ctx {
uint32_t tag;
};
-static int _restore_send_file_data(struct _restore_send_file_data_ctx* rctx, void* data, size_t size, size_t done, size_t total_size)
+static int _restore_send_file_data(struct _restore_send_file_data_ctx* rctx, const void* data, size_t size, size_t done, size_t total_size)
{
plist_t dict = plist_new_dict();
if (data != NULL) {
@@ -4221,12 +4221,9 @@ int restore_send_personalized_boot_object_v3(struct idevicerestore_client_t* cli
}
char *component = image_name;
- unsigned int size = 0;
- unsigned char *data = NULL;
+ size_t size = 0;
+ void *data = NULL;
char *path = NULL;
- plist_t blob = NULL;
- plist_t dict = NULL;
- restored_error_t restore_error = RESTORE_E_SUCCESS;
logger(LL_INFO, "About to send %s...\n", component);
@@ -4267,8 +4264,8 @@ int restore_send_personalized_boot_object_v3(struct idevicerestore_client_t* cli
}
// Extract component
- unsigned char *component_data = NULL;
- unsigned int component_size = 0;
+ void *component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, path, &component_data, &component_size);
free(path);
path = NULL;
@@ -4306,7 +4303,7 @@ int restore_send_personalized_boot_object_v3(struct idevicerestore_client_t* cli
int64_t i = size;
while (i > 0) {
int blob_size = i > 8192 ? 8192 : i;
- if (_restore_send_file_data(&rctx, (data + size - i), blob_size, size-i, size) < 0) {
+ if (_restore_send_file_data(&rctx, ((char*)data + size - i), blob_size, size-i, size) < 0) {
free(data);
_restore_service_free(service);
finalize_progress(rctx.tag);
@@ -4348,12 +4345,7 @@ int restore_send_source_boot_object_v4(struct idevicerestore_client_t* client, p
char *component = image_name;
// Fork from restore_send_component
//
- unsigned int size = 0;
- unsigned char *data = NULL;
char *path = NULL;
- plist_t blob = NULL;
- plist_t dict = NULL;
- restored_error_t restore_error = RESTORE_E_SUCCESS;
logger(LL_INFO, "About to send %s...\n", component);
@@ -4433,11 +4425,11 @@ int restore_send_source_boot_object_v4(struct idevicerestore_client_t* client, p
int restore_send_restore_local_policy(struct idevicerestore_client_t* client, plist_t message)
{
- unsigned int size = 0;
- unsigned char* data = NULL;
+ size_t size = 0;
+ void* data = NULL;
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
char* component = "Ap,LocalPolicy";
@@ -4562,8 +4554,8 @@ int restore_send_recovery_os_file_asset_image(struct idevicerestore_client_t* cl
return 0;
}
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, path, &component_data, &component_size);
free(path);
path = NULL;
@@ -4575,8 +4567,8 @@ int restore_send_recovery_os_file_asset_image(struct idevicerestore_client_t* cl
return 0;
}
- unsigned char* data = NULL;
- unsigned int size = 0;
+ void* data = NULL;
+ size_t size = 0;
ret = personalize_component(client, component, component_data, component_size, client->tss_recoveryos_root_ticket, &data, &size);
free(component_data);
component_data = NULL;
@@ -4634,12 +4626,12 @@ int restore_send_recovery_os_iboot_fw_files_images(struct idevicerestore_client_
plist_t comp_path = plist_access_path(manifest_entry, 2, "Info", "Path");
if (comp_path) {
const char* path = plist_get_string_ptr(comp_path, NULL);
- unsigned char* component_data = NULL;
- unsigned int component_size = 0;
+ void* component_data = NULL;
+ size_t component_size = 0;
int ret = extract_component(client->ipsw, path, &component_data, &component_size);
if (ret == 0) {
- unsigned char* data = NULL;
- unsigned int size = 0;
+ void* data = NULL;
+ size_t size = 0;
ret = personalize_component(client, component, component_data, component_size, client->tss_recoveryos_root_ticket, &data, &size);
free(component_data);
component_data = NULL;