diff --git a/msi.c b/msi.c index a1f5773..ed0ab71 100644 --- a/msi.c +++ b/msi.c @@ -734,7 +734,7 @@ out: } /* Compute a simple sha1/sha256 message digest of the MSI file */ -int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, uint32_t fileend) +int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, FILE_HEADER *header) { const EVP_MD *md = EVP_get_digestbynid(mdtype); BIO *bhash = BIO_new(BIO_f_md()); @@ -745,7 +745,7 @@ int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, uint32_t fileend) return 0; /* FAILED */ } BIO_push(bhash, BIO_new(BIO_s_null())); - if (!bio_hash_data(indata, bhash, 0, 0, fileend)) { + if (!bio_hash_data(indata, bhash, 0, 0, header->fileend)) { printf("Unable to calculate digest\n"); BIO_free_all(bhash); return 0; /* FAILED */ diff --git a/msi.h b/msi.h index eff3007..7abe058 100644 --- a/msi.h +++ b/msi.h @@ -143,6 +143,18 @@ typedef unsigned char u_char; +typedef struct { + uint32_t header_size; + uint32_t pe32plus; + uint16_t magic; + uint32_t pe_checksum; + uint32_t nrvas; + uint32_t sigpos; + uint32_t siglen; + uint32_t fileend; + uint16_t flags; +} FILE_HEADER; + typedef struct { u_char signature[8]; /* 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 */ u_char unused_clsid[16]; /* reserved and unused */ @@ -260,7 +272,7 @@ MSI_ENTRY *msi_signatures_get(MSI_DIRENT *dirent, MSI_ENTRY **dse); void msi_dirent_free(MSI_DIRENT *dirent); int msi_prehash_dir(MSI_DIRENT *dirent, BIO *hash, int is_root); int msi_hash_dir(MSI_FILE *msi, MSI_DIRENT *dirent, BIO *hash, int is_root); -int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, uint32_t fileend); +int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, FILE_HEADER *header); int msi_dirent_delete(MSI_DIRENT *dirent, const u_char *name, uint16_t nameLen); int msi_file_write(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p, uint32_t len, u_char *p_msiex, uint32_t len_msiex, BIO *outdata); diff --git a/osslsigncode.c b/osslsigncode.c index 08bce7d..b0e2901 100644 --- a/osslsigncode.c +++ b/osslsigncode.c @@ -257,18 +257,6 @@ typedef struct { #endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */ } GLOBAL_OPTIONS; -typedef struct { - uint32_t header_size; - uint32_t pe32plus; - uint16_t magic; - uint32_t pe_checksum; - uint32_t nrvas; - uint32_t sigpos; - uint32_t siglen; - uint32_t fileend; - uint16_t flags; -} FILE_HEADER; - typedef struct { EVP_PKEY *pkey; X509 *cert; @@ -4490,7 +4478,7 @@ static int cat_verify_member(CatalogAuthAttr *attribute, char *indata, FILE_HEAD goto out; break; case FILE_TYPE_MSI: - if (!msi_calc_digest(indata, mdtype, cmdbuf, header->fileend)) + if (!msi_calc_digest(indata, mdtype, cmdbuf, header)) goto out; break; default: