diff options
| author | 2022-10-04 14:36:57 +0200 | |
|---|---|---|
| committer | 2022-10-04 14:36:57 +0200 | |
| commit | 5debcee5a74550c28da735bb1cfc5b4c8f2614a9 (patch) | |
| tree | 7afdb56a63bb962e90945b2ecb22d44f46140b4e | |
| parent | ef7cf8eb545d9ed3fb1f351376dec71608d0127b (diff) | |
| download | libimobiledevice-5debcee5a74550c28da735bb1cfc5b4c8f2614a9.tar.gz libimobiledevice-5debcee5a74550c28da735bb1cfc5b4c8f2614a9.tar.bz2  | |
mobilebackup: Fix version check to allow operability with really old iOS versions
| -rw-r--r-- | src/mobilebackup.c | 20 | 
1 files changed, 18 insertions, 2 deletions
diff --git a/src/mobilebackup.c b/src/mobilebackup.c index aa29277..1505623 100644 --- a/src/mobilebackup.c +++ b/src/mobilebackup.c @@ -279,7 +279,15 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_backup(mobileback  		char *str = NULL;  		plist_get_string_val(node, &str);  		if (str) { -			if (strcmp(str, proto_version) != 0) { +			int maj = 0; +			int min = 0; +			sscanf(str, "%u.%u", &maj, &min); +			uint32_t this_ver = ((maj & 0xFF) << 8) | (min & 0xFF); +			maj = 0; +			min = 0; +			sscanf(proto_version, "%u.%u", &maj, &min); +			uint32_t proto_ver = ((maj & 0xFF) << 8) | (min & 0xFF); +			if (this_ver > proto_ver) {  				err = MOBILEBACKUP_E_BAD_VERSION;  			}  			free(str); @@ -346,7 +354,15 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_restore(mobilebac  		char *str = NULL;  		plist_get_string_val(node, &str);  		if (str) { -			if (strcmp(str, proto_version) != 0) { +			int maj = 0; +			int min = 0; +			sscanf(str, "%u.%u", &maj, &min); +			uint32_t this_ver = ((maj & 0xFF) << 8) | (min & 0xFF); +			maj = 0; +			min = 0; +			sscanf(proto_version, "%u.%u", &maj, &min); +			uint32_t proto_ver = ((maj & 0xFF) << 8) | (min & 0xFF); +			if (this_ver > proto_ver) {  				err = MOBILEBACKUP_E_BAD_VERSION;  			}  			free(str);  | 
