summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-08-11 23:31:26 +0200
committerGravatar Nikias Bassen2021-08-11 23:31:26 +0200
commit693bf2aa529e55deb8b9bd658c0d0e1dc4051e50 (patch)
treea8483eaff68cc01391c0045351b16ca2cd4bb38f /src
parent313b0d5ea1f33ceb78c860745befed8d660f447e (diff)
downloadidevicerestore-693bf2aa529e55deb8b9bd658c0d0e1dc4051e50.tar.gz
idevicerestore-693bf2aa529e55deb8b9bd658c0d0e1dc4051e50.tar.bz2
tss: Remove numerous free() calls and instead free at start of plist dictionary parsing loop
Diffstat (limited to 'src')
-rw-r--r--src/tss.c55
1 files changed, 12 insertions, 43 deletions
diff --git a/src/tss.c b/src/tss.c
index c2292bd..ae46e15 100644
--- a/src/tss.c
+++ b/src/tss.c
@@ -730,143 +730,116 @@ int tss_request_add_ap_recovery_tags(plist_t request, plist_t parameters, plist_
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
+ free(key);
+ key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
error("ERROR: Unable to fetch BuildManifest entry\n");
+ free(key);
return -1;
}
/* do not populate BaseBandFirmware, only in basebaseband request */
if ((strcmp(key, "BasebandFirmware") == 0)) {
- free(key);
continue;
}
// Compared to ac2, not needed for RecoveryOSRootTicket
if ((strcmp(key, "SE,UpdatePayload") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "BaseSystem") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "ANS") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,AudioBootChime") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,CIO") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,RestoreCIO") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,RestoreTMU") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,TMU") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,rOSLogo1") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "Ap,rOSLogo2") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "AppleLogo") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "DCP") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "LLB") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RecoveryMode") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreANS") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreDCP") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreDeviceTree") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreKernelCache") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreLogo") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreRamDisk") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "RestoreSEP") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "SEP") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "ftap") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "ftsp") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "iBEC") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "iBSS") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "rfta") == 0)) {
- free(key);
continue;
}
if ((strcmp(key, "rfts") == 0)) {
- free(key);
continue;
}
/* FIXME: only used with diagnostics firmware */
if (strcmp(key, "Diags") == 0) {
- free(key);
continue;
}
if (_plist_dict_get_bool(parameters, "_OnlyFWComponents")) {
if (!_plist_dict_get_bool(manifest_entry, "Trusted")) {
- debug("DEBUG: %s: Skipping '%s' as it is not trusted", __func__, key);
+ debug("DEBUG: %s: Skipping '%s' as it is not trusted\n", __func__, key);
continue;
}
@@ -903,9 +876,8 @@ int tss_request_add_ap_recovery_tags(plist_t request, plist_t parameters, plist_
/* finally add entry to request */
plist_dict_set_item(request, key, tss_entry);
-
- free(key);
}
+ free(key);
free(iter);
/* apply overrides */
@@ -930,35 +902,34 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
+ free(key);
+ key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
error("ERROR: Unable to fetch BuildManifest entry\n");
+ free(key);
return -1;
}
/* do not populate BaseBandFirmware, only in basebaseband request */
if ((strcmp(key, "BasebandFirmware") == 0)) {
- free(key);
continue;
}
// Compared to ac2, not needed
if ((strcmp(key, "SE,UpdatePayload") == 0)) {
- free(key);
continue;
}
// Compared to ac2, not needed
if ((strcmp(key, "BaseSystem") == 0)) {
- free(key);
continue;
}
/* FIXME: only used with diagnostics firmware */
if (strcmp(key, "Diags") == 0) {
- free(key);
continue;
}
@@ -1001,9 +972,8 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid
/* finally add entry to request */
plist_dict_set_item(request, key, tss_entry);
-
- free(key);
}
+ free(key);
free(iter);
/* apply overrides */
@@ -1193,18 +1163,18 @@ int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrid
plist_dict_iter iter = NULL;
plist_dict_new_iter(manifest_node, &iter);
while (1) {
+ free(key);
key = NULL;
plist_dict_next_item(manifest_node, iter, &key, &manifest_entry);
if (key == NULL)
break;
if (!manifest_entry || plist_get_node_type(manifest_entry) != PLIST_DICT) {
- free(key);
error("ERROR: Unable to fetch BuildManifest entry\n");
+ free(key);
return -1;
}
if (strncmp(key, "SE,", 3)) {
- free(key);
continue;
}
@@ -1229,9 +1199,8 @@ int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrid
/* add entry to request */
plist_dict_set_item(request, key, tss_entry);
-
- free(key);
}
+ free(key);
free(iter);
/* apply overrides */