mirror of
https://github.com/tihmstar/futurerestore.git
synced 2024-12-22 17:35:29 +00:00
fixed an issue which could lead to segfault sometimes
This commit is contained in:
parent
25ac142fbe
commit
64fbd4d536
|
@ -74,7 +74,7 @@ uint64_t futurerestore::getDeviceEcid(){
|
||||||
|
|
||||||
int futurerestore::getDeviceMode(bool reRequest){
|
int futurerestore::getDeviceMode(bool reRequest){
|
||||||
if (!_didInit) reterror(-1, "did not init\n");
|
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;
|
return _client->mode->index;
|
||||||
}else{
|
}else{
|
||||||
normal_client_free(_client);
|
normal_client_free(_client);
|
||||||
|
@ -243,23 +243,6 @@ uint64_t futurerestore::getBasebandGoldCertIDFromDevice(){
|
||||||
return val;
|
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 futurerestore::doRestore(const char *ipsw, bool noerase){
|
||||||
int err = 0;
|
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.
|
//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){
|
if (!_client->device || !_client->device->product_type){
|
||||||
|
|
||||||
int mode = getDeviceMode(true);
|
int mode = getDeviceMode(true);
|
||||||
|
@ -565,7 +548,7 @@ char *futurerestore::getLatestManifest(){
|
||||||
if (!__latestManifest){
|
if (!__latestManifest){
|
||||||
loadFirmwareTokens();
|
loadFirmwareTokens();
|
||||||
|
|
||||||
const char *device = getConnectedDeviceModel();
|
const char *device = getDeviceModelNoCopy();
|
||||||
t_iosVersion versVals;
|
t_iosVersion versVals;
|
||||||
memset(&versVals, 0, sizeof(versVals));
|
memset(&versVals, 0, sizeof(versVals));
|
||||||
|
|
||||||
|
@ -602,7 +585,7 @@ char *futurerestore::getLatestFirmwareUrl(){
|
||||||
|
|
||||||
void futurerestore::loadLatestBaseband(){
|
void futurerestore::loadLatestBaseband(){
|
||||||
char * manifeststr = getLatestManifest();
|
char * manifeststr = getLatestManifest();
|
||||||
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getConnectedDeviceModel(), 0);
|
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getDeviceModelNoCopy(), 0);
|
||||||
info("downloading Baseband\n\n");
|
info("downloading Baseband\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
||||||
reterror(-32, "could not download baseband\n");
|
reterror(-32, "could not download baseband\n");
|
||||||
|
@ -611,7 +594,7 @@ void futurerestore::loadLatestBaseband(){
|
||||||
|
|
||||||
void futurerestore::loadLatestSep(){
|
void futurerestore::loadLatestSep(){
|
||||||
char * manifeststr = getLatestManifest();
|
char * manifeststr = getLatestManifest();
|
||||||
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getConnectedDeviceModel(), 0);
|
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getDeviceModelNoCopy(), 0);
|
||||||
info("downloading SEP\n\n");
|
info("downloading SEP\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
||||||
reterror(-33, "could not download SEP\n");
|
reterror(-33, "could not download SEP\n");
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
plist_t nonceMatchesApTickets();
|
plist_t nonceMatchesApTickets();
|
||||||
|
|
||||||
void loadFirmwareTokens();
|
void loadFirmwareTokens();
|
||||||
const char *getConnectedDeviceModel();
|
const char *getDeviceModelNoCopy();
|
||||||
char *getLatestManifest();
|
char *getLatestManifest();
|
||||||
char *getLatestFirmwareUrl();
|
char *getLatestFirmwareUrl();
|
||||||
void loadLatestBaseband();
|
void loadLatestBaseband();
|
||||||
|
@ -81,7 +81,6 @@ public:
|
||||||
const char *basebandPath(){return _basebandPath;};
|
const char *basebandPath(){return _basebandPath;};
|
||||||
|
|
||||||
uint64_t getBasebandGoldCertIDFromDevice();
|
uint64_t getBasebandGoldCertIDFromDevice();
|
||||||
const char *getDeviceModelNoCopy();
|
|
||||||
|
|
||||||
int doRestore(const char *ipsw, bool noerase);
|
int doRestore(const char *ipsw, bool noerase);
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ int main(int argc, const char * argv[]) {
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
devVals.deviceModel = (char*)client.getDeviceModelNoCopy();
|
||||||
|
|
||||||
|
|
||||||
if (flags & FLAG_LATEST_SEP){
|
if (flags & FLAG_LATEST_SEP){
|
||||||
|
@ -167,7 +168,6 @@ int main(int argc, const char * argv[]) {
|
||||||
client.setBasebandManifestPath(basebandManifestPath);
|
client.setBasebandManifestPath(basebandManifestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
devVals.deviceModel = (char*)client.getDeviceModelNoCopy();
|
|
||||||
|
|
||||||
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
||||||
if (!(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), &devVals, &versVals))){
|
if (!(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), &devVals, &versVals))){
|
||||||
|
|
Loading…
Reference in a new issue