Skip to content

Commit

Permalink
Print device Product and Build Version and IPSW Product and Build Ver…
Browse files Browse the repository at this point in the history
…sion

It wasn't entirely clear what "Product Version" and "Product Build" would be
so prefixing it with "IPSW" makes it clear it's the version being restored.
  • Loading branch information
nikias committed Nov 7, 2023
1 parent c871c59 commit 8664de0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ struct idevicerestore_client_t {
struct idevicerestore_mode_t* mode;
char* version;
char* build;
char* device_version;
char* device_build;
int build_major;
char* restore_boot_args;
char* cache_dir;
Expand Down
42 changes: 24 additions & 18 deletions src/idevicerestore.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,21 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
return -1;
}

if (client->mode == MODE_NORMAL) {
plist_t pver = normal_get_lockdown_value(client, NULL, "ProductVersion");
if (pver) {
plist_get_string_val(pver, &client->device_version);
plist_free(pver);
}
pver = normal_get_lockdown_value(client, NULL, "BuildVersion");
if (pver) {
plist_get_string_val(pver, &client->device_build);
plist_free(pver);
}
}
info("Device Product Version: %s\n", (client->device_version) ? client->device_version : "N/A");
info("Device Product Build: %s\n", (client->device_build) ? client->device_build : "N/A");

if (client->flags & FLAG_PWN) {
recovery_client_free(client);

Expand Down Expand Up @@ -678,8 +693,8 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
/* print iOS information from the manifest */
build_manifest_get_version_information(client->build_manifest, client);

info("Product Version: %s\n", client->version);
info("Product Build: %s Major: %d\n", client->build, client->build_major);
info("IPSW Product Version: %s\n", client->version);
info("IPSW Product Build: %s Major: %d\n", client->build, client->build_major);

client->image4supported = is_image4_supported(client);
info("Device supports Image4: %s\n", (client->image4supported) ? "true" : "false");
Expand Down Expand Up @@ -872,17 +887,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}

if (client->mode == MODE_NORMAL && !(client->flags & FLAG_ERASE) && !(client->flags & FLAG_SHSHONLY)) {
plist_t pver = normal_get_lockdown_value(client, NULL, "ProductVersion");
char *device_version = NULL;
if (pver) {
plist_get_string_val(pver, &device_version);
plist_free(pver);
}
if (device_version && (compare_versions(device_version, client->version) > 0)) {
if (client->device_version && (compare_versions(client->device_version, client->version) > 0)) {
if (client->flags & FLAG_INTERACTIVE) {
char input[64];
char spaces[16];
int num_spaces = 13 - strlen(client->version) - strlen(device_version);
int num_spaces = 13 - strlen(client->version) - strlen(client->device_version);
memset(spaces, ' ', num_spaces);
spaces[num_spaces] = '\0';
printf("################################ [ WARNING ] #################################\n"
Expand All @@ -893,7 +902,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
"# If you want to take the risk (and have a backup of your important data!) #\n"
"# type YES and press ENTER to continue. You have been warned. #\n"
"##############################################################################\n",
device_version, client->version, spaces);
client->device_version, client->version, spaces);
while (1) {
printf("> ");
fflush(stdout);
Expand All @@ -912,7 +921,6 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
}
}
free(device_version);
}

if (client->flags & FLAG_ERASE && client->flags & FLAG_INTERACTIVE) {
Expand Down Expand Up @@ -1413,12 +1421,10 @@ void idevicerestore_client_free(struct idevicerestore_client_t* client)
}
free(client->filesystem);
}
if (client->version) {
free(client->version);
}
if (client->build) {
free(client->build);
}
free(client->version);
free(client->build);
free(client->device_version);
free(client->device_build);
if (client->restore_boot_args) {
free(client->restore_boot_args);
}
Expand Down

0 comments on commit 8664de0

Please sign in to comment.