diff options
author | Nikias Bassen | 2012-07-17 01:39:15 +0200 |
---|---|---|
committer | Nikias Bassen | 2012-07-17 01:39:15 +0200 |
commit | 57c4a013a91752a8d190e267d8f9fe73cacfcb5d (patch) | |
tree | 7649cd6152eb30f88acc4b4a2c7702a11d79bb47 /src | |
parent | 546e75e3ab6c27b0696da47c2b93dfbd5ea0c876 (diff) | |
download | idevicerestore-57c4a013a91752a8d190e267d8f9fe73cacfcb5d.tar.gz idevicerestore-57c4a013a91752a8d190e267d8f9fe73cacfcb5d.tar.bz2 |
ipsw: allow passing NULL as sha1buf to ipsw_get_latest_fw
Diffstat (limited to 'src')
-rw-r--r-- | src/ipsw.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -225,7 +225,9 @@ void ipsw_close(ipsw_archive* archive) { int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl, unsigned char* sha1buf) { *fwurl = NULL; - memset(sha1buf, '\0', 20); + if (sha1buf != NULL) { + memset(sha1buf, '\0', 20); + } plist_t n1 = plist_access_path(version_data, 2, "MobileDeviceMajorVersionsByProductType", product); if (!n1 || (plist_dict_get_size(n1) == 0)) { @@ -350,21 +352,23 @@ int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl, plist_get_string_val(n2, fwurl); - n2 = plist_access_path(n1, 2, "Restore", "FirmwareSHA1"); - if (n2 && plist_get_node_type(n2) == PLIST_STRING) { - strval = NULL; - plist_get_string_val(n2, &strval); - if (strval) { - if (strlen(strval) == 40) { - int i; - int v; - for (i = 0; i < 40; i+=2) { - v = 0; - sscanf(strval+i, "%02x", &v); - sha1buf[i/2] = (unsigned char)v; + if (sha1buf != NULL) { + n2 = plist_access_path(n1, 2, "Restore", "FirmwareSHA1"); + if (n2 && plist_get_node_type(n2) == PLIST_STRING) { + strval = NULL; + plist_get_string_val(n2, &strval); + if (strval) { + if (strlen(strval) == 40) { + int i; + int v; + for (i = 0; i < 40; i+=2) { + v = 0; + sscanf(strval+i, "%02x", &v); + sha1buf[i/2] = (unsigned char)v; + } } + free(strval); } - free(strval); } } |