From 57c4a013a91752a8d190e267d8f9fe73cacfcb5d Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 17 Jul 2012 01:39:15 +0200 Subject: ipsw: allow passing NULL as sha1buf to ipsw_get_latest_fw --- src/ipsw.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/ipsw.c') diff --git a/src/ipsw.c b/src/ipsw.c index 4389c54..9c78da9 100644 --- a/src/ipsw.c +++ b/src/ipsw.c @@ -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); } } -- cgit v1.1-32-gdbae