summaryrefslogtreecommitdiffstats
path: root/src/lockdown.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-07-29 03:36:29 +0200
committerGravatar Nikias Bassen2021-07-29 03:36:29 +0200
commit6c7b50355cc5de1da1d7677e012f18efbce34237 (patch)
tree9f70fb484fd9f4c5ecc65b4f2ca4fd4732c94e65 /src/lockdown.c
parent8e01e874113f430dc7a1835282ff93226863e47c (diff)
downloadlibimobiledevice-6c7b50355cc5de1da1d7677e012f18efbce34237.tar.gz
libimobiledevice-6c7b50355cc5de1da1d7677e012f18efbce34237.tar.bz2
lockdown: Get DeviceClass to make sure OS version dependent code is executed correctly
The code in lockdownd_client_new_with_handshake would call the function lockdownd_validate_pair based on the OS version being less than 7.0 without taking into account that Watch OS has a different versioning scheme compared to the other device classes. For this and any future version/device specific checks, the code now queries the DeviceClass and stores it in the idevice_private struct.
Diffstat (limited to 'src/lockdown.c')
-rw-r--r--src/lockdown.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 159f741..2cacc71 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -696,6 +696,30 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi
696 } 696 }
697 plist_free(p_version); 697 plist_free(p_version);
698 } 698 }
699 if (device->device_class == 0) {
700 plist_t p_device_class = NULL;
701 if (lockdownd_get_value(client_loc, NULL, "DeviceClass", &p_device_class) == LOCKDOWN_E_SUCCESS) {
702 char* s_device_class = NULL;
703 plist_get_string_val(p_device_class, &s_device_class);
704 if (s_device_class != NULL) {
705 if (!strcmp(s_device_class, "iPhone")) {
706 device->device_class = DEVICE_CLASS_IPHONE;
707 } else if (!strcmp(s_device_class, "iPad")) {
708 device->device_class = DEVICE_CLASS_IPAD;
709 } else if (!strcmp(s_device_class, "iPod")) {
710 device->device_class = DEVICE_CLASS_IPOD;
711 } else if (!strcmp(s_device_class, "Watch")) {
712 device->device_class = DEVICE_CLASS_WATCH;
713 } else if (!strcmp(s_device_class, "AppleTV")) {
714 device->device_class = DEVICE_CLASS_APPLETV;
715 } else {
716 device->device_class = DEVICE_CLASS_UNKNOWN;
717 }
718 free(s_device_class);
719 }
720 }
721 plist_free(p_device_class);
722 }
699 723
700 userpref_error_t uerr = userpref_read_pair_record(client_loc->udid, &pair_record); 724 userpref_error_t uerr = userpref_read_pair_record(client_loc->udid, &pair_record);
701 if (uerr == USERPREF_E_READ_ERROR) { 725 if (uerr == USERPREF_E_READ_ERROR) {
@@ -720,7 +744,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi
720 plist_free(pair_record); 744 plist_free(pair_record);
721 pair_record = NULL; 745 pair_record = NULL;
722 746
723 if (device->version < DEVICE_VERSION(7,0,0)) { 747 if (device->version < DEVICE_VERSION(7,0,0) && device->device_class != DEVICE_CLASS_WATCH) {
724 /* for older devices, we need to validate pairing to receive trusted host status */ 748 /* for older devices, we need to validate pairing to receive trusted host status */
725 ret = lockdownd_validate_pair(client_loc, NULL); 749 ret = lockdownd_validate_pair(client_loc, NULL);
726 750