summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-16 16:04:09 +0200
committerGravatar Nikias Bassen2012-07-16 16:04:09 +0200
commiteb2db6e2bedefa426fba43cc7a9d47d868a9d897 (patch)
treecdaf9aacecb4db22dc4e7ca02e4f6fa3fecdd41d
parentbc6be463e4b1f8284c7fa8115920d41df4241569 (diff)
downloadidevicerestore-eb2db6e2bedefa426fba43cc7a9d47d868a9d897.tar.gz
idevicerestore-eb2db6e2bedefa426fba43cc7a9d47d868a9d897.tar.bz2
use temporary filename for extracting filesystem from ipsw
-rw-r--r--src/idevicerestore.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 56bc44a..87a783f 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1183,13 +1183,23 @@ int ipsw_extract_filesystem(const char* ipsw, plist_t build_identity, char** fil
return -1;
}
+ char* outfile = tempnam(NULL, "ipsw_");
+ if (!outfile) {
+ error("WARNING: Could not get temporary filename!\n");
+ }
+
info("Extracting filesystem from IPSW\n");
- if (ipsw_extract_to_file(ipsw, filename, filename) < 0) {
+ if (ipsw_extract_to_file(ipsw, filename, (outfile) ? outfile : filename) < 0) {
error("ERROR: Unable to extract filesystem\n");
+ free(filename);
+ if (outfile) {
+ free(outfile);
+ }
return -1;
}
- *filesystem = filename;
+ *filesystem = outfile;
+ free(filename);
return 0;
}