summaryrefslogtreecommitdiffstats
path: root/src/ipsw.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-07-17 16:30:48 +0200
committerGravatar Nikias Bassen2012-07-17 16:30:48 +0200
commit2a2004af685091c55e8008cc0a00084ade471cfe (patch)
tree72a5f52eb0592161492597160f961fd6c51800c6 /src/ipsw.c
parentdd49ca170f19d8a4f8ceb67f4ad9b04c5137f3ff (diff)
downloadidevicerestore-2a2004af685091c55e8008cc0a00084ade471cfe.tar.gz
idevicerestore-2a2004af685091c55e8008cc0a00084ade471cfe.tar.bz2
ipsw: Prevent error about BuildManifesto.plist by checking if it exists first
Diffstat (limited to 'src/ipsw.c')
-rw-r--r--src/ipsw.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index 82abbda..789af60 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -126,6 +126,24 @@ int ipsw_extract_to_file(const char* ipsw, const char* infile, const char* outfi
return 0;
}
+int ipsw_file_exists(const char* ipsw, const char* infile)
+{
+ ipsw_archive* archive = ipsw_open(ipsw);
+ if (archive == NULL || archive->zip == NULL) {
+ return -1;
+ }
+
+ int zindex = zip_name_locate(archive->zip, infile, 0);
+ if (zindex < 0) {
+ ipsw_close(archive);
+ return -2;
+ }
+
+ ipsw_close(archive);
+
+ return 0;
+}
+
int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer, uint32_t* psize) {
ipsw_archive* archive = ipsw_open(ipsw);
if (archive == NULL || archive->zip == NULL) {
@@ -184,9 +202,11 @@ int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest, int *t
*tss_enabled = 0;
/* older devices don't require personalized firmwares and use a BuildManifesto.plist */
- if (ipsw_extract_to_memory(ipsw, "BuildManifesto.plist", &data, &size) == 0) {
- plist_from_xml(data, size, buildmanifest);
- return 0;
+ if (ipsw_file_exists(ipsw, "BuildManifesto.plist") == 0) {
+ if (ipsw_extract_to_memory(ipsw, "BuildManifesto.plist", &data, &size) == 0) {
+ plist_from_xml(data, size, buildmanifest);
+ return 0;
+ }
}
data = NULL;