From 2f82d2218c701e5cb891c3f8cef6236b5b2ccdd9 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 11 Dec 2019 13:05:12 -0800 Subject: [PATCH] =?UTF-8?q?[AltServer]=20Fixes=20erroneous=20=E2=80=9C3=20?= =?UTF-8?q?App=20Limit=20Reached=E2=80=9D=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AltServer/Devices/ALTDeviceManager.mm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/AltServer/Devices/ALTDeviceManager.mm b/AltServer/Devices/ALTDeviceManager.mm index 7dd88fe1..77e97c8b 100644 --- a/AltServer/Devices/ALTDeviceManager.mm +++ b/AltServer/Devices/ALTDeviceManager.mm @@ -279,13 +279,23 @@ NSErrorDomain const ALTDeviceErrorDomain = @"com.rileytestut.ALTDeviceError"; return finish(error); } - plist_t profiles = NULL; + plist_t rawProfiles = NULL; - if (misagent_copy_all(mis, &profiles) != MISAGENT_E_SUCCESS) + if (misagent_copy_all(mis, &rawProfiles) != MISAGENT_E_SUCCESS) { return finish([NSError errorWithDomain:AltServerErrorDomain code:ALTServerErrorConnectionFailed userInfo:nil]); } - + + // For some reason, libplist now fails to parse `rawProfiles` correctly. + // Specifically, it no longer recognizes the nodes in the plist array as "data" nodes. + // However, if we encode it as XML then decode it again, it'll work ¯\_(ツ)_/¯ + char *plistXML = nullptr; + uint32_t plistLength = 0; + plist_to_xml(rawProfiles, &plistXML, &plistLength); + + plist_t profiles = NULL; + plist_from_xml(plistXML, plistLength, &profiles); + uint32_t profileCount = plist_array_get_size(profiles); for (int i = 0; i < profileCount; i++) { @@ -294,7 +304,7 @@ NSErrorDomain const ALTDeviceErrorDomain = @"com.rileytestut.ALTDeviceError"; { continue; } - + char *bytes = NULL; uint64_t length = 0; @@ -346,6 +356,9 @@ NSErrorDomain const ALTDeviceErrorDomain = @"com.rileytestut.ALTDeviceError"; NSLog(@"Failed to remove provisioning profile %@ (Team: %@). Error Code: %@", provisioningProfile.bundleIdentifier, provisioningProfile.teamIdentifier, @(code)); } } + + plist_free(rawProfiles); + plist_free(profiles); lockdownd_client_free(client); client = NULL;