Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Build the vendored restore C code without warnings

Lakr233c2433edddf72
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRecoveryCore/libirecovery.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRecoveryCore/libirecovery.c
index 35341f9a..77289174 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRecoveryCore/libirecovery.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRecoveryCore/libirecovery.c
@@ -744,7 +744,7 @@ INITIALIZER(_irecv_init)
{
char* dbglvl = getenv("LIBIRECOVERY_DEBUG_LEVEL");
if (dbglvl) {
- libirecovery_debug = strtol(dbglvl, NULL, 0);
+ libirecovery_debug = (int)strtol(dbglvl, NULL, 0);
irecv_set_debug_level(libirecovery_debug);
}
#ifndef USE_DUMMY
@@ -946,7 +946,7 @@ static void irecv_load_device_info_from_iboot_string(irecv_client_t client, cons
static void irecv_copy_nonce_with_tag_from_buffer(const char* tag, unsigned char** nonce, unsigned int* nonce_size, const char *buf)
{
- int taglen = strlen(tag);
+ int taglen = (int)strlen(tag);
int nlen = 0;
const char* nonce_string = NULL;
const char* p = buf;
@@ -962,9 +962,9 @@ static void irecv_copy_nonce_with_tag_from_buffer(const char* tag, unsigned char
if (strncmp(colon-taglen, tag, taglen) == 0) {
p = colon+1;
if (!space) {
- nlen = strlen(p);
+ nlen = (int)strlen(p);
} else {
- nlen = space-p;
+ nlen = (int)(space-p);
}
nonce_string = p;
nlen/=2;
@@ -1081,7 +1081,7 @@ static irecv_error_t irecv_kis_request(irecv_client_t client, KIS_req_header *re
}
int sent = 0;
- irecv_error_t err = irecv_usb_bulk_transfer(client, endpoint, (unsigned char *) req, reqSize, &sent, USB_TIMEOUT);
+ irecv_error_t err = irecv_usb_bulk_transfer(client, endpoint, (unsigned char *) req, (int)reqSize, &sent, USB_TIMEOUT);
if (err != IRECV_E_SUCCESS) {
debug("[send] irecv_usb_bulk_transfer failed, error %d\n", err);
return err;
@@ -1093,7 +1093,7 @@ static irecv_error_t irecv_kis_request(irecv_client_t client, KIS_req_header *re
}
int rcvd = 0;
- err = irecv_usb_bulk_transfer(client, endpoint | 0x80, (unsigned char *) rpl, *rplSize, &rcvd, USB_TIMEOUT);
+ err = irecv_usb_bulk_transfer(client, endpoint | 0x80, (unsigned char *) rpl, (int)*rplSize, &rcvd, USB_TIMEOUT);
if (err != IRECV_E_SUCCESS) {
debug("[rcv] irecv_usb_bulk_transfer failed, error %d\n", err);
return err;
@@ -3475,7 +3475,7 @@ const char* irecv_version()
#ifndef USE_DUMMY
static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command, uint8_t b_request)
{
- unsigned int length = strlen(command);
+ unsigned int length = (unsigned int)strlen(command);
if (length >= 0x100) {
return IRECV_E_INVALID_INPUT;
}
@@ -3527,7 +3527,7 @@ irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
- unsigned int length = strlen(command);
+ unsigned int length = (unsigned int)strlen(command);
if (length >= 0x100) {
return IRECV_E_INVALID_INPUT;
}
@@ -3655,7 +3655,7 @@ static irecv_error_t irecv_kis_send_buffer(irecv_client_t client, unsigned char*
}
chunk->address = address;
- chunk->size = toUpload;
+ chunk->size = (uint32_t)toUpload;
memcpy(chunk->data, buffer, toUpload);
#endif
@@ -3683,7 +3683,7 @@ static irecv_error_t irecv_kis_send_buffer(irecv_client_t client, unsigned char*
event.progress = ((double) (origLen - length) / (double) origLen) * 100.0;
event.type = IRECV_PROGRESS;
event.data = (char*)"Uploading";
- event.size = origLen - length;
+ event.size = (int)(origLen - length);
client->progress_callback(client, &event);
} else {
debug("Sent: %lu bytes - %lu of %lu\n", toUpload, origLen - length, origLen);
@@ -3698,7 +3698,7 @@ static irecv_error_t irecv_kis_send_buffer(irecv_client_t client, unsigned char*
int ret = DeviceIoControl(client->handle, 0x22000C, &amount, 4, NULL, 0, (PDWORD)&transferred, NULL);
irecv_error_t error = (ret) ? IRECV_E_SUCCESS : IRECV_E_USB_UPLOAD;
#else
- irecv_error_t error = irecv_kis_config_write32(client, KIS_PORTAL_RSM, KIS_INDEX_BOOT_IMG, origLen);
+ irecv_error_t error = irecv_kis_config_write32(client, KIS_PORTAL_RSM, KIS_INDEX_BOOT_IMG, (uint32_t)origLen);
#endif
if (error != IRECV_E_SUCCESS) {
debug("Failed to boot image, error %d\n", error);
@@ -3758,7 +3758,7 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un
dfu_crc = 0;
}
int last = length % packet_size;
- int packets = length / packet_size;
+ int packets = (int)(length / packet_size);
if (last != 0) {
packets++;
@@ -3913,7 +3913,7 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un
event.progress = ((double) count/ (double) length) * 100.0;
event.type = IRECV_PROGRESS;
event.data = (char*)"Uploading";
- event.size = count;
+ event.size = (int)count;
client->progress_callback(client, &event);
} else {
debug("Sent: %d bytes - %lu of %lu\n", bytes, count, length);
@@ -4349,7 +4349,7 @@ irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned lo
int packet_size = recovery_mode ? 0x2000: 0x800;
int last = length % packet_size;
- int packets = length / packet_size;
+ int packets = (int)(length / packet_size);
if (last != 0) {
packets++;
} else {
@@ -4373,7 +4373,7 @@ irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned lo
event.progress = ((double) count/ (double) length) * 100.0;
event.type = IRECV_PROGRESS;
event.data = (char*)"Downloading";
- event.size = count;
+ event.size = (int)count;
client->progress_callback(client, &event);
} else {
debug("Sent: %d bytes - %lu of %lu\n", bytes, count, length);
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/common.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/common.c
index 70f07428..4a38dd46 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/common.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/common.c
@@ -99,7 +99,7 @@ int write_file(const char* filename, const void* data, size_t size) {
return -1;
}
- return size;
+ return (int)size;
}
int read_file(const char* filename, void** data, size_t* size) {
@@ -149,7 +149,7 @@ int read_file(const char* filename, void** data, size_t* size) {
int process_text_lines(const char* text, int maxwidth, struct tuple** lines_out, int* maxlen_out)
{
if (!text) return 0;
- int len = strlen(text);
+ int len = (int)strlen(text);
int numlines = 0;
int maxlen = 0;
int linestart = 0;
@@ -261,7 +261,7 @@ int prompt_user(const char* title, const char* text)
struct tuple* lines = NULL;
int numlines = process_text_lines(text, 74, &lines, &maxlen);
int outerlen = maxlen+4;
- int titlelen = (title) ? strlen(title) : 0;
+ int titlelen = (title) ? (int)strlen(title) : 0;
if (titlelen > 0) {
int lefttitlelen = (titlelen+4)/2;
int leftpounds = outerlen/2 - lefttitlelen;
@@ -275,7 +275,7 @@ int prompt_user(const char* title, const char* text)
}
free(lines);
const char* yesmsg = "Type YES and press ENTER to continue, or hit CTRL+C to cancel.";
- int ylen = strlen(yesmsg);
+ int ylen = (int)strlen(yesmsg);
printf("%c %.*s%.*s %c\n", *POUNDS, ylen, yesmsg, maxlen-ylen, SPACES, *POUNDS);
printf("%.*s\n", outerlen, POUNDS);
@@ -456,7 +456,7 @@ char *generate_guid(void)
{
char *guid = (char *) malloc(sizeof(char) * 37);
const char *chars = "ABCDEF0123456789";
- srand(time(NULL));
+ srand((unsigned int)time(NULL));
int i = 0;
for (i = 0; i < 36; i++) {
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/idevicerestore.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/idevicerestore.c
index e400fee0..bffd3284 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/idevicerestore.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Core/idevicerestore.c
@@ -236,7 +236,7 @@ static int load_version_data(struct idevicerestore_client_t* client)
}
client->version_data = NULL;
- plist_from_xml(verbuf, verlen, &client->version_data);
+ plist_from_xml(verbuf, (uint32_t)verlen, &client->version_data);
free(verbuf);
if (!client->version_data) {
@@ -2969,7 +2969,7 @@ void build_manifest_get_version_information(plist_t build_manifest, struct idevi
}
plist_get_string_val(node, &client->build);
- client->build_major = strtoul(client->build, NULL, 10);
+ client->build_major = (int)strtoul(client->build, NULL, 10);
}
void build_identity_print_information(plist_t build_identity)
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/fls.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/fls.c
index 8b747a93..67f4355b 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/fls.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/fls.c
@@ -155,7 +155,7 @@ int fls_update_sig_blob(fls_file* fls, const void* sigdata, size_t siglen)
return -1;
}
- size_t oldsiglen = datasize - sigoffset;
+ uint32_t oldsiglen = datasize - sigoffset;
size_t newsize = fls->size - oldsiglen + siglen;
unsigned int i;
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/ftab.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/ftab.c
index d0fc26b8..325f14fd 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/ftab.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Containers/ftab.c
@@ -127,7 +127,7 @@ int ftab_add_entry(ftab_t ftab, uint32_t tag, const void *data, size_t data_size
ftab->storage[new_index] = data_copy;
ftab->entries[new_index].tag = tag;
- ftab->entries[new_index].size = data_size;
+ ftab->entries[new_index].size = (uint32_t)data_size;
ftab->header.num_entries++;
uint32_t off = sizeof(struct ftab_header) + sizeof(struct ftab_entry) * ftab->header.num_entries;
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/ace3.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/ace3.c
index d51613dc..ace62ac1 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/ace3.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/ace3.c
@@ -126,7 +126,7 @@ int ace3_create_binary(const void* uarp_fw, size_t uarp_size, uint64_t bdid, uns
struct uarp_header* uarp_hdr = (struct uarp_header*)uarp_fw;
uint32_t uarp_hdr_size = be32toh(uarp_hdr->header_size);
uint32_t plist_offset = be32toh(uarp_hdr->plist_offset);
- uint32_t plist_size = uarp_size - plist_offset;
+ uint32_t plist_size = (uint32_t)(uarp_size - plist_offset);
nskeyedarchive_t ka = nskeyedarchive_new_from_data(uarp_fw + plist_offset, plist_size);
if (!ka) {
return -1;
@@ -241,7 +241,7 @@ int ace3_create_binary(const void* uarp_fw, size_t uarp_size, uint64_t bdid, uns
p += te_size;
}
- uint32_t content_size = data1_size + data2_size + im4m_size + dl_size;
+ uint32_t content_size = (uint32_t)(data1_size + data2_size + im4m_size + dl_size);
*bin_out = malloc(0x40 + content_size);
struct ace3bin_header* hdr = (struct ace3bin_header*)(*bin_out);
@@ -252,7 +252,7 @@ int ace3_create_binary(const void* uarp_fw, size_t uarp_size, uint64_t bdid, uns
hdr->data1_size = htole32(data1_size);
hdr->data2_size = htole32(data2_size);;
hdr->im4m_offset = htole32(0x40 + data1_size + data2_size);
- hdr->im4m_dl_size = htole32(im4m_size + dl_size);
+ hdr->im4m_dl_size = htole32((uint32_t)(im4m_size + dl_size));
hdr->content_size = htole32(content_size);
hdr->crc = 0;
hdr->fill1 = 0xFFFFFFFFFFFFFFFFLL;
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img3.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img3.c
index db50703f..f18b0afe 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img3.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img3.c
@@ -415,7 +415,7 @@ int img3_stitch_component(const char* component_name, const void* component_data
logger(LL_INFO, "Personalizing IMG3 component %s...\n", component_name);
/* parse current component as img3 */
- img3 = img3_parse_file(component_data, component_size);
+ img3 = img3_parse_file(component_data, (unsigned int)component_size);
if (img3 == NULL) {
logger(LL_ERROR, "Unable to parse %s IMG3 file\n", component_name);
return -1;
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img4.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img4.c
index 732ef69e..843d2135 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img4.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Firmware/Images/img4.c
@@ -166,7 +166,7 @@ static void asn1_write_element(unsigned char **p, unsigned int *length, unsigned
case ASN1_IA5_STRING: {
char *str = (char*)data;
size_t len = (data_len < 0) ? strlen(str) : data_len;
- asn1_write_element_header(type, len, p, &this_len);
+ asn1_write_element_header(type, (unsigned int)len, p, &this_len);
*length += this_len;
memcpy(*p, str, len);
*p += len;
@@ -570,16 +570,16 @@ int img4_stitch_component(const char* component_name, const void* component_data
unsigned char *p_inner_seq = &inner_seq[0];
unsigned int inner_seq_hdr_len = 0;
asn1_write_element(&p_inner_seq, &inner_seq_hdr_len, ASN1_IA5_STRING, (void*)"ucon", -1);
- asn1_write_element_header(ASN1_OCTET_STRING, ucon_size, &p_inner_seq, &inner_seq_hdr_len);
+ asn1_write_element_header(ASN1_OCTET_STRING, (unsigned int)ucon_size, &p_inner_seq, &inner_seq_hdr_len);
// write ucon sequence
unsigned char elem_seq[8];
unsigned char *p = &elem_seq[0];
unsigned int seq_hdr_len = 0;
- asn1_write_element_header(ASN1_SEQUENCE | ASN1_CONSTRUCTED, inner_seq_hdr_len + ucon_size, &p, &seq_hdr_len);
+ asn1_write_element_header(ASN1_SEQUENCE | ASN1_CONSTRUCTED, inner_seq_hdr_len + (unsigned int)ucon_size, &p, &seq_hdr_len);
// add size to priv ucon element
- asn1_write_size(inner_seq_hdr_len + ucon_size + seq_hdr_len, &p_im4rset, &im4rlen);
+ asn1_write_size(inner_seq_hdr_len + (unsigned int)ucon_size + seq_hdr_len, &p_im4rset, &im4rlen);
// put it together
memcpy(p_im4rset, elem_seq, seq_hdr_len);
@@ -604,16 +604,16 @@ int img4_stitch_component(const char* component_name, const void* component_data
unsigned char *p_inner_seq = &inner_seq[0];
unsigned int inner_seq_hdr_len = 0;
asn1_write_element(&p_inner_seq, &inner_seq_hdr_len, ASN1_IA5_STRING, (void*)"ucer", -1);
- asn1_write_element_header(ASN1_OCTET_STRING, ucer_size, &p_inner_seq, &inner_seq_hdr_len);
+ asn1_write_element_header(ASN1_OCTET_STRING, (unsigned int)ucer_size, &p_inner_seq, &inner_seq_hdr_len);
// write ucer sequence
unsigned char elem_seq[8];
unsigned char *p = &elem_seq[0];
unsigned int seq_hdr_len = 0;
- asn1_write_element_header(ASN1_SEQUENCE | ASN1_CONSTRUCTED, inner_seq_hdr_len + ucer_size, &p, &seq_hdr_len);
+ asn1_write_element_header(ASN1_SEQUENCE | ASN1_CONSTRUCTED, inner_seq_hdr_len + (unsigned int)ucer_size, &p, &seq_hdr_len);
// add size to priv ucer element
- asn1_write_size(inner_seq_hdr_len + ucer_size + seq_hdr_len, &p_im4rset, &im4rlen);
+ asn1_write_size(inner_seq_hdr_len + (unsigned int)ucer_size + seq_hdr_len, &p_im4rset, &im4rlen);
// put it together
memcpy(p_im4rset, elem_seq, seq_hdr_len);
@@ -678,7 +678,7 @@ int img4_stitch_component(const char* component_name, const void* component_data
asn1_create_element_header(ASN1_CONTEXT_SPECIFIC|ASN1_CONSTRUCTED, blob_size, &blob_header, &blob_header_size);
// calculate the size for the final IMG4 file (asn1 sequence)
- content_size = magic_header_size + IMG4_MAGIC_SIZE + component_size + blob_header_size + blob_size + additional_size;
+ content_size = (unsigned int)(magic_header_size + IMG4_MAGIC_SIZE + component_size + blob_header_size + blob_size + additional_size);
// create element header for the final IMG4 asn1 blob
asn1_create_element_header(ASN1_SEQUENCE|ASN1_CONSTRUCTED, content_size, &img4header, &img4header_size);
@@ -798,7 +798,7 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c
uint64_t digest_len = 0;
const char *digest = plist_get_data_ptr(node, &digest_len);
if (digest_len > 0) {
- _manifest_write_key_value(&tmp, &tmp_len, "DGST", ASN1_OCTET_STRING, (void*)digest, digest_len);
+ _manifest_write_key_value(&tmp, &tmp_len, "DGST", ASN1_OCTET_STRING, (void*)digest, (int)digest_len);
}
}
@@ -839,7 +839,7 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c
if (!tbmtag) {
logger(LL_ERROR, "Unexpected TMBDigests for comp '%s'\n", tag);
} else {
- _manifest_write_key_value(&tmp, &tmp_len, tbmtag, ASN1_OCTET_STRING, (void*)data, datalen);
+ _manifest_write_key_value(&tmp, &tmp_len, tbmtag, ASN1_OCTET_STRING, (void*)data, (int)datalen);
}
}
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/asr.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/asr.c
index 66f65e7b..1bd65598 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/asr.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/asr.c
@@ -180,7 +180,7 @@ 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);
+ device_error = idevice_connection_send(asr->connection, data, (uint32_t)size, &bytes);
if (device_error != IDEVICE_E_SUCCESS || bytes != size) {
logger(LL_ERROR, "Unable to send data to ASR. Sent %u of %zu bytes.\n", bytes, size);
return -1;
@@ -372,7 +372,7 @@ int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file)
uint32_t sendsize = 0;
if (i < ASR_PAYLOAD_CHUNK_SIZE) {
- size = i;
+ size = (uint32_t)i;
}
if (ipsw_file_read(file, data, size) != (int64_t)size) {
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/fdr.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/fdr.c
index 9dbe59c6..1c9fcb37 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/fdr.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/fdr.c
@@ -486,7 +486,7 @@ static int fdr_handle_proxy_cmd(fdr_client_t fdr)
{
idevice_error_t device_error = IDEVICE_E_SUCCESS;
char *buf = NULL;
- size_t bufsize = 1048576;
+ uint32_t bufsize = 1048576;
uint32_t sent = 0, bytes = 0;
char *host = NULL;
uint16_t port = 0;
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/ipsw.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/ipsw.c
index cebfa493..60482b6f 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/ipsw.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/ipsw.c
@@ -358,7 +358,7 @@ int ipsw_get_file_size(ipsw_archive_t ipsw, const char* infile, uint64_t* size)
logger(LL_ERROR, "zip_open: %s: %d\n", ipsw->path, err);
return -1;
}
- int zindex = zip_name_locate(zip, infile, 0);
+ zip_int64_t zindex = zip_name_locate(zip, infile, 0);
if (zindex < 0) {
logger(LL_ERROR, "zip_name_locate: %s\n", infile);
zip_unchange_all(zip);
@@ -412,7 +412,7 @@ int ipsw_extract_to_file_with_progress(ipsw_archive_t ipsw, const char* infile,
return -1;
}
- int zindex = zip_name_locate(zip, infile, 0);
+ zip_int64_t zindex = zip_name_locate(zip, infile, 0);
if (zindex < 0) {
zip_unchange_all(zip);
zip_close(zip);
@@ -464,8 +464,8 @@ int ipsw_extract_to_file_with_progress(ipsw_archive_t ipsw, const char* infile,
break;
}
if (i < BUFSIZE)
- size = i;
- count = zip_fread(zfile, buffer, size);
+ size = (int)i;
+ count = (int)zip_fread(zfile, buffer, size);
if (count < 0) {
int zep = 0;
int sep = 0;
@@ -605,7 +605,7 @@ int ipsw_file_exists(ipsw_archive_t ipsw, const char* infile)
logger(LL_ERROR, "zip_open: %s: %d\n", ipsw->path, err);
return 0;
}
- int zindex = zip_name_locate(zip, infile, 0);
+ zip_int64_t zindex = zip_name_locate(zip, infile, 0);
zip_unchange_all(zip);
zip_close(zip);
if (zindex < 0) {
@@ -640,7 +640,7 @@ int ipsw_extract_to_memory(ipsw_archive_t ipsw, const char* infile, void** pbuff
return -1;
}
- int zindex = zip_name_locate(zip, infile, 0);
+ zip_int64_t zindex = zip_name_locate(zip, infile, 0);
if (zindex < 0) {
zip_unchange_all(zip);
zip_close(zip);
@@ -782,7 +782,7 @@ int ipsw_extract_send(ipsw_archive_t ipsw, const char* infile, int blocksize, ip
return -1;
}
- int zindex = zip_name_locate(zip, infile, 0);
+ zip_int64_t zindex = zip_name_locate(zip, infile, 0);
if (zindex < 0) {
zip_unchange_all(zip);
zip_close(zip);
@@ -921,7 +921,7 @@ int ipsw_extract_build_manifest(ipsw_archive_t ipsw, plist_t* buildmanifest, int
/* 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_memory((char*)data, size, buildmanifest, NULL);
+ plist_from_memory((char*)data, (uint32_t)size, buildmanifest, NULL);
free(data);
return 0;
}
@@ -933,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_memory((char*)data, size, buildmanifest, NULL);
+ plist_from_memory((char*)data, (uint32_t)size, buildmanifest, NULL);
free(data);
return 0;
}
@@ -947,7 +947,7 @@ int ipsw_extract_restore_plist(ipsw_archive_t ipsw, plist_t* restore_plist)
void* data = NULL;
if (ipsw_extract_to_memory(ipsw, "Restore.plist", &data, &size) == 0) {
- plist_from_memory((char*)data, size, restore_plist, NULL);
+ plist_from_memory((char*)data, (uint32_t)size, restore_plist, NULL);
free(data);
return 0;
}
@@ -1104,7 +1104,7 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
logger(LL_ERROR, "Download from %s failed.\n", url);
return -1;
}
- plist_from_json(jdata, jsize, &dict);
+ plist_from_json(jdata, (uint32_t)jsize, &dict);
free(jdata);
if (!dict || plist_get_node_type(dict) != PLIST_DICT) {
logger(LL_ERROR, "Failed to parse json data.\n");
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/restore.c b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/restore.c
index 1913835d..903fa609 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/restore.c
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/Transfer/restore.c
@@ -2364,7 +2364,7 @@ static int restore_send_baseband_data(struct idevicerestore_client_t* client, pl
response = NULL;
}
- res = restore_sign_bbfw(bbfwtmp, (client->restore->bbtss) ? client->restore->bbtss : response, bb_nonce, bb_chip_id);
+ res = restore_sign_bbfw(bbfwtmp, (client->restore->bbtss) ? client->restore->bbtss : response, bb_nonce, (uint32_t)bb_chip_id);
if (res != 0) {
goto leave;
}
@@ -3192,10 +3192,10 @@ static plist_t restore_get_veridian_firmware_data(struct idevicerestore_client_t
}
plist_t fw_map = NULL;
- if (plist_is_binary((const char*)component_data, component_size)) {
- plist_from_bin((const char*)component_data, component_size, &fw_map);
+ if (plist_is_binary((const char*)component_data, (uint32_t)component_size)) {
+ plist_from_bin((const char*)component_data, (uint32_t)component_size, &fw_map);
} else {
- plist_from_xml((const char*)component_data, component_size, &fw_map);
+ plist_from_xml((const char*)component_data, (uint32_t)component_size, &fw_map);
}
free(component_data);
component_data = NULL;
@@ -3957,19 +3957,19 @@ static int cpio_send_file(idevice_connection_t connection, const char *name, str
memset(&hdr, '0', sizeof(hdr));
memcpy(hdr.c_magic, "070707", 6);
octal(hdr.c_dev, 6, st->st_dev);
- octal(hdr.c_ino, 6, st->st_ino);
+ octal(hdr.c_ino, 6, (int)st->st_ino);
octal(hdr.c_mode, 6, st->st_mode);
octal(hdr.c_uid, 6, st->st_uid);
octal(hdr.c_gid, 6, st->st_gid);
octal(hdr.c_nlink, 6, st->st_nlink);
octal(hdr.c_rdev, 6, st->st_rdev);
- octal(hdr.c_mtime, 11, st->st_mtime);
- octal(hdr.c_namesize, 6, strlen(name) + 1);
+ octal(hdr.c_mtime, 11, (int)st->st_mtime);
+ octal(hdr.c_namesize, 6, (int)(strlen(name) + 1));
if (data)
- octal(hdr.c_filesize, 11, st->st_size);
+ octal(hdr.c_filesize, 11, (int)st->st_size);
uint32_t bytes = 0;
- int name_len = strlen(name) + 1;
+ int name_len = (int)(strlen(name) + 1);
idevice_error_t device_error;
device_error = idevice_connection_send(connection, (void *)&hdr, sizeof(hdr), &bytes);
@@ -3985,7 +3985,7 @@ static int cpio_send_file(idevice_connection_t connection, const char *name, str
}
if (st->st_size && data) {
- device_error = idevice_connection_send(connection, data, st->st_size, &bytes);
+ device_error = idevice_connection_send(connection, data, (uint32_t)st->st_size, &bytes);
if (device_error != IDEVICE_E_SUCCESS || bytes != st->st_size) {
logger(LL_ERROR, "BootabilityBundle unable to send data. (%d) Sent %u of %lu bytes.\n", device_error, bytes, (long)st->st_size);
return -1;
@@ -4366,7 +4366,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;
+ int blob_size = i > 8192 ? 8192 : (int)i;
if (_restore_send_file_data(&rctx, ((char*)data + size - i), blob_size, size-i, size) < 0) {
free(data);
_restore_service_free(service);
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/config.h b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/config.h
index d939e001..41056cfe 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/config.h
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/MobileRestoreCore/config.h
@@ -9,7 +9,11 @@
* header directory and becomes the generated module's umbrella, and no
* dependent should inherit a PACKAGE_VERSION it did not ask for. Two targets
* in this package now carry a config.h, and if both were public they would
- * collide in any translation unit that imported both modules.
+ * collide in any translation unit that imported both modules. For the same
+ * reason both C targets build with USE_HEADERMAP = NO: Xcode's project header
+ * map indexes every header in the project by bare name, so a quoted
+ * "config.h" here (or in libimobiledevice-glue's termcolors.h) would resolve
+ * to libirecovery's copy instead, and the two would be stacked in one unit.
* `.headerSearchPath(".")` plus `.define("HAVE_CONFIG_H")` is what reaches it.
*
* Every value below is read off upstream's configure.ac rather than guessed:
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/VPhoneRestore.xcodeproj/project.pbxproj b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/VPhoneRestore.xcodeproj/project.pbxproj
index a68fca80..d5860737 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneRestore/VPhoneRestore.xcodeproj/project.pbxproj
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneRestore/VPhoneRestore.xcodeproj/project.pbxproj
@@ -358,6 +358,7 @@
PRODUCT_NAME = MobileRecoveryCore;
SDKROOT = macosx;
SKIP_INSTALL = YES;
+ USE_HEADERMAP = NO;
};
name = Debug;
};
@@ -382,6 +383,7 @@
PRODUCT_NAME = MobileRecoveryCore;
SDKROOT = macosx;
SKIP_INSTALL = YES;
+ USE_HEADERMAP = NO;
};
name = Release;
};
@@ -415,6 +417,7 @@
PRODUCT_NAME = MobileRestoreCore;
SDKROOT = macosx;
SKIP_INSTALL = YES;
+ USE_HEADERMAP = NO;
};
name = Debug;
};
@@ -448,6 +451,7 @@
PRODUCT_NAME = MobileRestoreCore;
SDKROOT = macosx;
SKIP_INSTALL = YES;
+ USE_HEADERMAP = NO;
};
name = Release;
};