From eb2db6e2bedefa426fba43cc7a9d47d868a9d897 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 16 Jul 2012 16:04:09 +0200 Subject: use temporary filename for extracting filesystem from ipsw --- src/idevicerestore.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/idevicerestore.c') 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; } -- cgit v1.1-32-gdbae