From a808accd1e748184933f0e4d97d499d79f34f889 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 23 Jan 2019 01:19:46 +0100 Subject: Replace tempnam() with mkstemp() and provide reference implementation for systems lacking it --- src/restore.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 6652aa0..a187dfa 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1627,15 +1627,18 @@ int restore_send_baseband_data(restored_client_t restore, struct idevicerestore_ } // extract baseband firmware to temp file - bbfwtmp = tempnam(NULL, client->udid); + bbfwtmp = get_temp_filename("bbfw_"); if (!bbfwtmp) { - error("WARNING: Could not generate temporary filename, using bbfw.tmp\n"); - bbfwtmp = strdup("bbfw.tmp"); + size_t l = strlen(client->udid); + bbfwtmp = malloc(l + 10); + strcpy(bbfwtmp, "bbfw_"); + strncpy(bbfwtmp + 5, client->udid, l); + strcpy(bbfwtmp + 5 + l, ".tmp"); + error("WARNING: Could not generate temporary filename, using %s in current directory\n", bbfwtmp); } if (ipsw_extract_to_file(client->ipsw, bbfwpath, bbfwtmp) != 0) { error("ERROR: Unable to extract baseband firmware from ipsw\n"); - plist_free(response); - return -1; + goto leave; } if (bb_nonce && !client->restore->bbtss) { -- cgit v1.1-32-gdbae