]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_codesigning/lib/notarization.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_codesigning / lib / notarization.cpp
index fa75c0d02c4678e2255cece8008421cadf0516ff..6587dccdc4ed1552a8d595042b06dbbc8f5fcbf7 100644 (file)
@@ -49,9 +49,9 @@ registerStapledTicketWithSystem(CFDataRef data)
        secinfo("notarization", "Registering stapled ticket with system");
 
 #if TARGET_OS_OSX
        secinfo("notarization", "Registering stapled ticket with system");
 
 #if TARGET_OS_OSX
-       CFErrorRef error = NULL;
-       if (!SecAssessmentTicketRegister(data, &error)) {
-               secerror("Error registering stapled ticket: %@", data);
+       CFRef<CFErrorRef> error;
+       if (!SecAssessmentTicketRegister(data, &error.aref())) {
+               secerror("Error registering stapled ticket: %@", error.get());
        }
 #endif // TARGET_OS_OSX
 }
        }
 #endif // TARGET_OS_OSX
 }
@@ -208,7 +208,7 @@ registerStapledTicketInPackage(const std::string& path)
                goto lb_exit;
        }
 
                goto lb_exit;
        }
 
-       data = CFDataCreateWithBytesNoCopy(NULL, ticketData, trailer.length, NULL);
+       data.take(makeCFDataMalloc(ticketData, trailer.length));
        if (data.get() == NULL) {
                secerror("unable to create cfdata for notarization");
                goto lb_exit;
        if (data.get() == NULL) {
                secerror("unable to create cfdata for notarization");
                goto lb_exit;
@@ -221,9 +221,6 @@ lb_exit:
        if (fd) {
                close(fd);
        }
        if (fd) {
                close(fd);
        }
-       if (ticketData) {
-               free(ticketData);
-       }
 }
 
 void
 }
 
 void
@@ -277,7 +274,7 @@ registerStapledTicketInBundle(const std::string& path)
                goto lb_exit;
        }
 
                goto lb_exit;
        }
 
-       data = CFDataCreateWithBytesNoCopy(NULL, ticketData, ticketLength, NULL);
+       data.take(makeCFDataMalloc(ticketData, ticketLength));
        if (data.get() == NULL) {
                secerror("unable to create cfdata for notarization");
                goto lb_exit;
        if (data.get() == NULL) {
                secerror("unable to create cfdata for notarization");
                goto lb_exit;
@@ -290,9 +287,6 @@ lb_exit:
        if (fd) {
                close(fd);
        }
        if (fd) {
                close(fd);
        }
-       if (ticketData) {
-               free(ticketData);
-       }
 }
 
 void
 }
 
 void
@@ -305,5 +299,15 @@ registerStapledTicketInDMG(CFDataRef ticketData)
        registerStapledTicketWithSystem(ticketData);
 }
 
        registerStapledTicketWithSystem(ticketData);
 }
 
+void
+registerStapledTicketInMachO(CFDataRef ticketData)
+{
+       if (ticketData == NULL) {
+               return;
+       }
+       secinfo("notarization", "successfully found stapled ticket in MachO");
+       registerStapledTicketWithSystem(ticketData);
+}
+
 }
 }
 }
 }