From 3d8be2d2dacea68e1a68f13d12ddfc78b3a0c4b4 Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Tue, 24 Jul 2012 09:13:47 -0700 Subject: [PATCH] Fixed potential crasher in code signing in the case that the host application is not code signed. --- SUCodeSigningVerifier.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUCodeSigningVerifier.m b/SUCodeSigningVerifier.m index 5adbb665..0dc029f0 100644 --- a/SUCodeSigningVerifier.m +++ b/SUCodeSigningVerifier.m @@ -26,10 +26,11 @@ extern OSStatus SecStaticCodeCheckValidityWithErrors(SecStaticCodeRef staticCode // This API didn't exist prior to 10.6. if (SecCodeCopySelf == NULL) return NO; - SecRequirementRef requirement = NULL; OSStatus result; - + SecRequirementRef requirement = NULL; + SecStaticCodeRef staticCode = NULL; SecCodeRef hostCode = NULL; + result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode); if (result != 0) { SULog(@"Failed to copy host code %d", result); @@ -42,7 +43,6 @@ extern OSStatus SecStaticCodeCheckValidityWithErrors(SecStaticCodeRef staticCode goto finally; } - SecStaticCodeRef staticCode = NULL; NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath]; if (!newBundle) { SULog(@"Failed to load NSBundle for update");