OcAppleKernelLib: Fix assertion when patching AppleImage4
@@ -1840,7 +1840,14 @@ PatchForceSecureBootScheme (
UINT8 *HybridAp;
UINT32 Diff;
- ASSERT (Patcher != NULL);
+ if (!OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_BIG_SUR_MIN, 0)) {
+ DEBUG ((DEBUG_INFO, "OCAK: Skipping sb scheme on %u\n", KernelVersion));
+ return EFI_SUCCESS;
+ }
+
+ if (Patcher == NULL) {
+ return EFI_NOT_FOUND;
+ }
//
// This code is for debugging APFS snapshot verification for Big Sur.
@@ -1857,11 +1864,6 @@ PatchForceSecureBootScheme (
// for platfirms with v2 or newer coprocessor and personalised policy (2).
//
- if (!OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_BIG_SUR_MIN, 0)) {
- DEBUG ((DEBUG_INFO, "OCAK: Skipping sb scheme on %u\n", KernelVersion));
- return EFI_SUCCESS;
- }
-
Last = ((UINT8 *) MachoGetMachHeader (&Patcher->MachContext)
+ MachoGetFileSize (&Patcher->MachContext) - 64);
