summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-16 16:08:01 +0200
committerGravatar Nikias Bassen2012-07-16 16:08:01 +0200
commitf0d950b94f9baeeb311663de26c5a68ff58bb3f5 (patch)
tree1752bea85959e6ee0d2b632b57ba841bfa53b750 /src
parent4211f24424a4b22b5941a52e8acd988a500488ee (diff)
downloadidevicerestore-f0d950b94f9baeeb311663de26c5a68ff58bb3f5.tar.gz
idevicerestore-f0d950b94f9baeeb311663de26c5a68ff58bb3f5.tar.bz2
main: use version.xml.tmp instead of tmpnam()
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 87a783f..e0a9e9c 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -95,17 +95,11 @@ static int load_version_data(struct idevicerestore_client_t* client)
int cached = 0;
if ((stat(VERSION_XML, &fst) < 0) || ((time(NULL)-86400) > fst.st_mtime)) {
- char tmpf[256];
- tmpf[0] = '\0';
- if (!tmpnam(tmpf) || (tmpf[0] == '\0')) {
- error("ERROR: Could not get temporary filename\n");
- return -1;
- }
+ __mkdir("cache", 0755);
- if (download_to_file("http://ax.itunes.apple.com/check/version", tmpf) == 0) {
- __mkdir("cache", 0755);
+ if (download_to_file("http://ax.itunes.apple.com/check/version", VERSION_XML ".tmp") == 0) {
remove(VERSION_XML);
- if (rename(tmpf, VERSION_XML) < 0) {
+ if (rename(VERSION_XML ".tmp", VERSION_XML) < 0) {
error("ERROR: Could not update '" VERSION_XML "'\n");
} else {
info("NOTE: Updated version data.\n");
@@ -125,6 +119,7 @@ static int load_version_data(struct idevicerestore_client_t* client)
client->version_data = NULL;
plist_from_xml(verbuf, verlen, &client->version_data);
+ free(verbuf);
if (!client->version_data) {
error("ERROR: Cannot parse plist data from '" VERSION_XML "'.\n");