Skip to content

Commit

Permalink
fixed Windows / Cygwin / MinGW compile
Browse files Browse the repository at this point in the history
  • Loading branch information
batmaninpink committed Aug 31, 2015
1 parent 4ef0e54 commit e72a193
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions osslsigncode.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
OpenSSL based Authenticode signing for PE/MSI/Java CAB files.
Copyright (C) 2005-2014 Per Allansson <[email protected]>
Copyright (C) 2005-2015 Per Allansson <[email protected]>
This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -61,30 +61,37 @@ static const char *rcsid = "$Id: osslsigncode.c,v 1.7.1 2014/07/11 14:14:14 mfiv
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#include "config.h"
#endif

#ifdef HAVE_WINDOWS_H
#define NOCRYPT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef unsigned char u_char;
#endif

#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#ifndef _WIN32
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif

#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#endif

#ifdef WITH_GSF
#include <gsf/gsf-infile-msole.h>
Expand All @@ -110,6 +117,11 @@ static const char *rcsid = "$Id: osslsigncode.c,v 1.7.1 2014/07/11 14:14:14 mfiv
#endif

#ifdef ENABLE_CURL
#ifdef __CYGWIN__
#ifndef SOCKET
#define SOCKET UINT_PTR
#endif
#endif
#include <curl/curl.h>

#define MAX_TS_SERVERS 256
Expand Down Expand Up @@ -2289,8 +2301,15 @@ static STACK_OF(X509) *PEM_read_certs(BIO *bin, char *certpass)

static off_t get_file_size(const char *infile)
{
int ret;
#ifdef _WIN32
struct _stat st;
ret = _stat(infile, &st);
#else
struct stat st;
if (stat(infile, &st))
ret = stat(infile, &st);
#endif
if (ret)
{
fprintf(stderr, "Failed to open file: %s\n", infile);
return 0;
Expand Down Expand Up @@ -2631,7 +2650,7 @@ int main(int argc, char **argv)
int passfd = open(readpass, O_RDONLY);
if (passfd < 0)
DO_EXIT_1("Failed to open password file: %s\n", readpass);
ssize_t passlen = read(passfd, passbuf, sizeof(passbuf)-1);
int passlen = read(passfd, passbuf, sizeof(passbuf)-1);
close(passfd);
if (passlen <= 0)
DO_EXIT_1("Failed to read password from file: %s\n", readpass);
Expand Down Expand Up @@ -3100,7 +3119,7 @@ int main(int argc, char **argv)
}
else if (type == FILE_TYPE_MSI) {
#ifdef WITH_GSF
const unsigned char *p = insigdata;
const unsigned char *p = (unsigned char*)insigdata;
sig = d2i_PKCS7(NULL, &p, sigfilesize);
#else
DO_EXIT_1("libgsf is not available, msi support is disabled: %s\n", infile);
Expand Down

0 comments on commit e72a193

Please sign in to comment.