]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_codesigning/lib/notarization.cpp
Security-59306.120.7.tar.gz
[apple/security.git] / OSX / libsecurity_codesigning / lib / notarization.cpp
index 91a2c15f54e3ba025669d8ec840777cfe77563e1..f645fd2eec9130864442b899b1d11ffdf9986e9e 100644 (file)
@@ -22,7 +22,7 @@
  */
 #include "SecAssessment.h"
 #include "notarization.h"
-#include "unix++.h"
+#include <security_utilities/unix++.h>
 
 typedef struct __attribute__((packed)) _package_trailer {
        uint8_t magic[4];
@@ -49,9 +49,9 @@ registerStapledTicketWithSystem(CFDataRef data)
        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
 }
@@ -208,7 +208,7 @@ registerStapledTicketInPackage(const std::string& path)
                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;
@@ -221,9 +221,6 @@ lb_exit:
        if (fd) {
                close(fd);
        }
-       if (ticketData) {
-               free(ticketData);
-       }
 }
 
 void
@@ -277,7 +274,7 @@ registerStapledTicketInBundle(const std::string& path)
                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;
@@ -290,9 +287,6 @@ lb_exit:
        if (fd) {
                close(fd);
        }
-       if (ticketData) {
-               free(ticketData);
-       }
 }
 
 void