fixed an issue which could lead to segfault sometimes

This commit is contained in:
tihmstar 2016-12-31 19:06:39 +01:00
parent 25ac142fbe
commit 64fbd4d536
3 changed files with 7 additions and 25 deletions

View file

@ -74,7 +74,7 @@ uint64_t futurerestore::getDeviceEcid(){
int futurerestore::getDeviceMode(bool reRequest){
if (!_didInit) reterror(-1, "did not init\n");
if (!reRequest && _client->mode->index != MODE_UNKNOWN) {
if (!reRequest && _client->mode && _client->mode->index != MODE_UNKNOWN) {
return _client->mode->index;
}else{
normal_client_free(_client);
@ -243,23 +243,6 @@ uint64_t futurerestore::getBasebandGoldCertIDFromDevice(){
return val;
}
const char *futurerestore::getDeviceModelNoCopy(){
if (!_client->device || !_client->device->product_type){
if (check_mode(_client) < 0) {
error("ERROR: Unable to discover device mode. Please make sure a device is attached.\n");
return NULL;
}
if (check_hardware_model(_client) == NULL || _client->device == NULL) {
error("ERROR: Unable to discover device model\n");
return NULL;
}
}
return _client->device->product_type;
}
int futurerestore::doRestore(const char *ipsw, bool noerase){
int err = 0;
//some memory might not get freed if this function throws an exception, but you probably don't want to catch that anyway.
@ -547,7 +530,7 @@ void futurerestore::loadFirmwareTokens(){
}
}
const char *futurerestore::getConnectedDeviceModel(){
const char *futurerestore::getDeviceModelNoCopy(){
if (!_client->device || !_client->device->product_type){
int mode = getDeviceMode(true);
@ -565,7 +548,7 @@ char *futurerestore::getLatestManifest(){
if (!__latestManifest){
loadFirmwareTokens();
const char *device = getConnectedDeviceModel();
const char *device = getDeviceModelNoCopy();
t_iosVersion versVals;
memset(&versVals, 0, sizeof(versVals));
@ -602,7 +585,7 @@ char *futurerestore::getLatestFirmwareUrl(){
void futurerestore::loadLatestBaseband(){
char * manifeststr = getLatestManifest();
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getConnectedDeviceModel(), 0);
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getDeviceModelNoCopy(), 0);
info("downloading Baseband\n\n");
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
reterror(-32, "could not download baseband\n");
@ -611,7 +594,7 @@ void futurerestore::loadLatestBaseband(){
void futurerestore::loadLatestSep(){
char * manifeststr = getLatestManifest();
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getConnectedDeviceModel(), 0);
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getDeviceModelNoCopy(), 0);
info("downloading SEP\n\n");
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
reterror(-33, "could not download SEP\n");

View file

@ -63,7 +63,7 @@ public:
plist_t nonceMatchesApTickets();
void loadFirmwareTokens();
const char *getConnectedDeviceModel();
const char *getDeviceModelNoCopy();
char *getLatestManifest();
char *getLatestFirmwareUrl();
void loadLatestBaseband();
@ -81,7 +81,6 @@ public:
const char *basebandPath(){return _basebandPath;};
uint64_t getBasebandGoldCertIDFromDevice();
const char *getDeviceModelNoCopy();
int doRestore(const char *ipsw, bool noerase);

View file

@ -150,6 +150,7 @@ int main(int argc, const char * argv[]) {
}
goto error;
}
devVals.deviceModel = (char*)client.getDeviceModelNoCopy();
if (flags & FLAG_LATEST_SEP){
@ -167,7 +168,6 @@ int main(int argc, const char * argv[]) {
client.setBasebandManifestPath(basebandManifestPath);
}
devVals.deviceModel = (char*)client.getDeviceModelNoCopy();
versVals.basebandMode = kBasebandModeWithoutBaseband;
if (!(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), &devVals, &versVals))){