]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_codesigning/lib/machorep.cpp
Security-55471.14.18.tar.gz
[apple/security.git] / libsecurity_codesigning / lib / machorep.cpp
index 2130171d7659bb8d01a55899cf51aacf9811d189..7d9f5d02309f56a512adfc501e7e518e576c8d4b 100644 (file)
@@ -47,14 +47,15 @@ MachORep::MachORep(const char *path, const Context *ctx)
 {
        if (ctx)
                if (ctx->offset)
-                       mExecutable = new Universal(fd(), (size_t)ctx->offset);
+                       mExecutable = new Universal(fd(), (size_t)ctx->offset, ctx->size);
                else if (ctx->arch) {
                        auto_ptr<Universal> full(new Universal(fd()));
-                       mExecutable = new Universal(fd(), full->archOffset(ctx->arch));
+                       mExecutable = new Universal(fd(), full->archOffset(ctx->arch), full->archLength(ctx->arch));
                } else
                        mExecutable = new Universal(fd());
        else
                mExecutable = new Universal(fd());
+
        assert(mExecutable);
        CODESIGN_DISKREP_CREATE_MACHO(this, (char*)path, (void*)ctx);
 }
@@ -248,12 +249,13 @@ string MachORep::format()
 void MachORep::flush()
 {
        size_t offset = mExecutable->offset();
+       size_t length = mExecutable->length();
        delete mExecutable;
        mExecutable = NULL;
        ::free(mSigningData);
        mSigningData = NULL;
        SingleDiskRep::flush();
-       mExecutable = new Universal(fd(), offset);
+       mExecutable = new Universal(fd(), offset, length);
 }
 
 
@@ -359,6 +361,16 @@ size_t MachORep::pageSize(const SigningContext &)
 }
 
 
+//
+// Strict validation
+//
+void MachORep::strictValidate(const ToleratedErrors& tolerated)
+{
+       if (mExecutable->isSuspicious() && tolerated.find(errSecCSBadMainExecutable) == tolerated.end())
+               MacOSError::throwMe(errSecCSBadMainExecutable);
+}
+
+
 //
 // FileDiskRep::Writers
 //