fixed the segfault maybe (at least didn't fuck up anything)

This commit is contained in:
tihmstar 2016-12-29 12:16:15 +01:00
parent fc1a67655e
commit 22cc9a54d1
3 changed files with 48 additions and 21 deletions

View file

@ -12,9 +12,7 @@
878587AB1D89D590008689F0 /* libimobiledevice.6.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587AA1D89D590008689F0 /* libimobiledevice.6.dylib */; };
878587AD1D89D59E008689F0 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587AC1D89D59E008689F0 /* libz.tbd */; };
878587AF1D89D5A5008689F0 /* libcurl.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587AE1D89D5A5008689F0 /* libcurl.tbd */; };
878587B11D89D5B0008689F0 /* libcrypto.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587B01D89D5B0008689F0 /* libcrypto.tbd */; };
878587B31D89D5D5008689F0 /* libzip.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587B21D89D5D5008689F0 /* libzip.4.dylib */; };
878587B51D89D5E6008689F0 /* libpartialzip-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587B41D89D5E6008689F0 /* libpartialzip-1.0.0.dylib */; };
878587B71D89D637008689F0 /* libirecovery.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 878587B61D89D637008689F0 /* libirecovery.2.dylib */; };
8799B0B21D89D99D002F4D5F /* futurerestore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8799B0B01D89D99D002F4D5F /* futurerestore.cpp */; };
8799B0B31D89DAE7002F4D5F /* idevicerestore.c in Sources */ = {isa = PBXBuildFile; fileRef = 8785875C1D89D1C1008689F0 /* idevicerestore.c */; settings = {COMPILER_FLAGS = "-D HAVE_CONFIG_H=1 "; }; };
@ -41,6 +39,8 @@
8799B0CB1D89F796002F4D5F /* tsschecker.c in Sources */ = {isa = PBXBuildFile; fileRef = 8785879F1D89D2BA008689F0 /* tsschecker.c */; };
8799B0CC1D89F7B9002F4D5F /* download.c in Sources */ = {isa = PBXBuildFile; fileRef = 878587981D89D2BA008689F0 /* download.c */; };
8799B0CD1D89F7B9002F4D5F /* jsmn.c in Sources */ = {isa = PBXBuildFile; fileRef = 8785879A1D89D2BA008689F0 /* jsmn.c */; };
87F574CB1E151E97008D5C4D /* libfragmentzip.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 87F574CA1E151E97008D5C4D /* libfragmentzip.0.dylib */; };
87F574D01E151F44008D5C4D /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 87F574C51E151D42008D5C4D /* libcrypto.dylib */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -116,12 +116,16 @@
878587AA1D89D590008689F0 /* libimobiledevice.6.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libimobiledevice.6.dylib; path = ../../../../usr/local/lib/libimobiledevice.6.dylib; sourceTree = "<group>"; };
878587AC1D89D59E008689F0 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
878587AE1D89D5A5008689F0 /* libcurl.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcurl.tbd; path = usr/lib/libcurl.tbd; sourceTree = SDKROOT; };
878587B01D89D5B0008689F0 /* libcrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcrypto.tbd; path = usr/lib/libcrypto.tbd; sourceTree = SDKROOT; };
878587B21D89D5D5008689F0 /* libzip.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libzip.4.dylib; path = ../../../../usr/local/lib/libzip.4.dylib; sourceTree = "<group>"; };
878587B41D89D5E6008689F0 /* libpartialzip-1.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libpartialzip-1.0.0.dylib"; path = "../../../../usr/local/lib/libpartialzip-1.0.0.dylib"; sourceTree = "<group>"; };
878587B61D89D637008689F0 /* libirecovery.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libirecovery.2.dylib; path = ../../../../usr/local/lib/libirecovery.2.dylib; sourceTree = "<group>"; };
8799B0B01D89D99D002F4D5F /* futurerestore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = futurerestore.cpp; sourceTree = "<group>"; };
8799B0B11D89D99D002F4D5F /* futurerestore.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = futurerestore.hpp; sourceTree = "<group>"; };
87F574C51E151D42008D5C4D /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = ../../../../usr/lib/libcrypto.dylib; sourceTree = "<group>"; };
87F574C71E151DA6008D5C4D /* libcommonCrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcommonCrypto.tbd; path = usr/lib/system/libcommonCrypto.tbd; sourceTree = SDKROOT; };
87F574CA1E151E97008D5C4D /* libfragmentzip.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfragmentzip.0.dylib; path = ../../../../usr/local/lib/libfragmentzip.0.dylib; sourceTree = "<group>"; };
87F574CC1E151EF8008D5C4D /* libcorecrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcorecrypto.tbd; path = usr/lib/system/libcorecrypto.tbd; sourceTree = SDKROOT; };
87F574CE1E151F11008D5C4D /* libSystem.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libSystem.tbd; path = usr/lib/libSystem.tbd; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -129,10 +133,10 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
87F574D01E151F44008D5C4D /* libcrypto.dylib in Frameworks */,
87F574CB1E151E97008D5C4D /* libfragmentzip.0.dylib in Frameworks */,
878587B71D89D637008689F0 /* libirecovery.2.dylib in Frameworks */,
878587B51D89D5E6008689F0 /* libpartialzip-1.0.0.dylib in Frameworks */,
878587B31D89D5D5008689F0 /* libzip.4.dylib in Frameworks */,
878587B11D89D5B0008689F0 /* libcrypto.tbd in Frameworks */,
878587AF1D89D5A5008689F0 /* libcurl.tbd in Frameworks */,
878587AD1D89D59E008689F0 /* libz.tbd in Frameworks */,
878587AB1D89D590008689F0 /* libimobiledevice.6.dylib in Frameworks */,
@ -149,7 +153,6 @@
878587B61D89D637008689F0 /* libirecovery.2.dylib */,
878587B41D89D5E6008689F0 /* libpartialzip-1.0.0.dylib */,
878587B21D89D5D5008689F0 /* libzip.4.dylib */,
878587B01D89D5B0008689F0 /* libcrypto.tbd */,
878587AE1D89D5A5008689F0 /* libcurl.tbd */,
878587AC1D89D59E008689F0 /* libz.tbd */,
878587AA1D89D590008689F0 /* libimobiledevice.6.dylib */,
@ -157,6 +160,7 @@
878587A61D89D56E008689F0 /* libplist.3.dylib */,
878587451D89CFDC008689F0 /* futurerestore */,
878587441D89CFDC008689F0 /* Products */,
87F574C21E151CDE008D5C4D /* Frameworks */,
);
sourceTree = "<group>";
};
@ -266,6 +270,18 @@
path = external/tsschecker/tsschecker;
sourceTree = SOURCE_ROOT;
};
87F574C21E151CDE008D5C4D /* Frameworks */ = {
isa = PBXGroup;
children = (
87F574CE1E151F11008D5C4D /* libSystem.tbd */,
87F574CC1E151EF8008D5C4D /* libcorecrypto.tbd */,
87F574CA1E151E97008D5C4D /* libfragmentzip.0.dylib */,
87F574C71E151DA6008D5C4D /* libcommonCrypto.tbd */,
87F574C51E151D42008D5C4D /* libcrypto.dylib */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -440,7 +456,12 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
HEADER_SEARCH_PATHS = "";
LIBRARY_SEARCH_PATHS = /usr/local/lib;
LIBRARY_SEARCH_PATHS = (
/usr/local/lib,
/usr/lib,
"$(SDKROOT)/usr/lib/system",
/opt/local/lib,
);
OTHER_CFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "/usr/local/include /opt/local/include";
@ -452,7 +473,12 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
HEADER_SEARCH_PATHS = "";
LIBRARY_SEARCH_PATHS = /usr/local/lib;
LIBRARY_SEARCH_PATHS = (
/usr/local/lib,
/usr/lib,
"$(SDKROOT)/usr/lib/system",
/opt/local/lib,
);
OTHER_CFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "/usr/local/include /opt/local/include";

View file

@ -31,7 +31,6 @@
#define __mkdir(path, mode) mkdir(path, mode)
#endif
#define NONCESIZE 20
#define USEC_PER_SEC 1000000
#define TMP_PATH "/tmp"
@ -131,10 +130,10 @@ bool futurerestore::nonceMatchesApTicket(){
int realNonceSize = 0;
recovery_get_ap_nonce(_client, &realnonce, &realNonceSize);
return memcmp(realnonce, (unsigned const char*)getNonceFromIM4M(_im4m), realNonceSize) == 0;
return memcmp(realnonce, (unsigned const char*)getNonceFromIM4M(_im4m,NULL), realNonceSize) == 0;
}
void futurerestore::waitForNonce(const char *nonce){
void futurerestore::waitForNonce(const char *nonce, size_t nonceSize){
if (!_didInit) reterror(-1, "did not init\n");
setAutoboot(false);
@ -143,7 +142,7 @@ void futurerestore::waitForNonce(const char *nonce){
info("waiting for nonce: ");
int i = 0;
for (i = 0; i < NONCESIZE; i++) {
for (i = 0; i < nonceSize; i++) {
info("%02x ", ((unsigned char *)nonce)[i]);
}
info("\n");
@ -171,7 +170,8 @@ void futurerestore::waitForNonce(const char *nonce){
}
void futurerestore::waitForNonce(){
if (!_im4m) reterror(-1, "No IM4M loaded\n");
waitForNonce(getNonceFromIM4M(_im4m));
size_t nonceSize;
waitForNonce(getNonceFromIM4M(_im4m,&nonceSize),nonceSize);
}
@ -572,7 +572,7 @@ inline void futurerestore::saveStringToFile(const char *str, const char *path){
}
}
char *futurerestore::getNonceFromIM4M(const char* im4m){
char *futurerestore::getNonceFromIM4M(const char* im4m, size_t *nonceSize){
char *ret = NULL;
t_asn1Tag *mainSet = NULL;
t_asn1Tag *manbSet = NULL;
@ -610,11 +610,12 @@ char *futurerestore::getNonceFromIM4M(const char* im4m){
goto error;
}
nonceOctet = (char*)asn1ElementAtIndex(bnch, 1);
nonceOctet++;
ret = (char*)malloc(NONCESIZE);
ret = (char*)malloc(asn1Len(nonceOctet).dataLen);
if (ret){
nonceOctet++;
memcpy(ret, nonceOctet + asn1Len(nonceOctet).sizeBytes, NONCESIZE);
memcpy(ret, nonceOctet + asn1Len(nonceOctet).sizeBytes, asn1Len(nonceOctet).dataLen);
if (nonceSize) *nonceSize = asn1Len(nonceOctet).dataLen;
}
@ -626,7 +627,7 @@ error:
char *futurerestore::getNonceFromAPTicket(const char* apticketPath){
char *ret = NULL;
if (char *im4m = im4mFormShshFile(apticketPath)){
ret = getNonceFromIM4M(im4m);
ret = getNonceFromIM4M(im4m,NULL);
free(im4m);
}
return ret;

View file

@ -55,7 +55,7 @@ public:
void putDeviceIntoRecovery();
void setAutoboot(bool val);
void waitForNonce();
void waitForNonce(const char *nonce);
void waitForNonce(const char *nonce, size_t nonceSize);
void loadAPTicket(const char *apticketPath);
void loadAPTicket(string apticketPath);
@ -83,8 +83,8 @@ public:
int doRestore(const char *ipsw, bool noerase);
~futurerestore();
static char *getNonceFromIM4M(const char* im4m);
static char *getNonceFromIM4M(const char* im4m, size_t *nonceSize);
static char *getNonceFromAPTicket(const char* apticketPath);
static plist_t loadPlistFromFile(const char *path);
static void saveStringToFile(const char *str, const char *path);