Fix compilation under Windows. Allocate our hash buffer dynamically so

that _chkstk doesn't throw a hissy fit. When hashing, open the file in
binary mode.

svn path=/trunk/; revision=31192
This commit is contained in:
Gerald Combs 2009-12-08 00:13:57 +00:00
parent 7c276becfd
commit e5be652056
3 changed files with 32 additions and 28 deletions

View File

@ -138,7 +138,8 @@ rawshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
capinfos_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ capinfos_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
wsock32.lib user32.lib shell32.lib \ wsock32.lib user32.lib shell32.lib \
wsutil\libwsutil.lib \ wsutil\libwsutil.lib \
$(GLIB_LIBS) $(GLIB_LIBS) \
$(GCRYPT_LIBS)
editcap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ editcap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
wsock32.lib user32.lib shell32.lib \ wsock32.lib user32.lib shell32.lib \

View File

@ -75,6 +75,7 @@
#include <wsutil/privileges.h> #include <wsutil/privileges.h>
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
#include <winposixtype.h>
#include <gcrypt.h> #include <gcrypt.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#endif #endif
@ -684,7 +685,7 @@ main(int argc, char *argv[])
#endif #endif
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
FILE *fh; FILE *fh;
char hash_buf[HASH_BUF_SIZE]; char *hash_buf = NULL;
gcry_md_hd_t hd; gcry_md_hd_t hd;
size_t hash_bytes; size_t hash_bytes;
#endif #endif
@ -856,6 +857,7 @@ main(int argc, char *argv[])
gcry_md_enable(hd, GCRY_MD_RMD160); gcry_md_enable(hd, GCRY_MD_RMD160);
gcry_md_enable(hd, GCRY_MD_MD5); gcry_md_enable(hd, GCRY_MD_MD5);
} }
hash_buf = g_malloc(HASH_BUF_SIZE);
} }
#endif #endif
@ -867,7 +869,7 @@ main(int argc, char *argv[])
strcpy(file_md5, "<unknown>"); strcpy(file_md5, "<unknown>");
if (cap_file_hashes) { if (cap_file_hashes) {
fh = ws_fopen(argv[opt], "r"); fh = ws_fopen(argv[opt], "rb");
if (fh && hd) { if (fh && hd) {
while((hash_bytes = fread(hash_buf, 1, HASH_BUF_SIZE, fh)) > 0) { while((hash_bytes = fread(hash_buf, 1, HASH_BUF_SIZE, fh)) > 0) {
gcry_md_write(hd, hash_buf, hash_bytes); gcry_md_write(hd, hash_buf, hash_bytes);

View File

@ -1047,10 +1047,11 @@ NETTLE_CONFIG=
GNUTLS_PATH=$(GNUTLS_DIR) GNUTLS_PATH=$(GNUTLS_DIR)
# /DNOCRYPT avoids inclusion of Wincrypt.h, avoiding a X509_NAME define clash # /DNOCRYPT avoids inclusion of Wincrypt.h, avoiding a X509_NAME define clash
GNUTLS_CFLAGS=/I$(GNUTLS_DIR)\include /DNOCRYPT /DIMPORT_LIGNUTLSDLL GNUTLS_CFLAGS=/I$(GNUTLS_DIR)\include /DNOCRYPT /DIMPORT_LIGNUTLSDLL
GCRYPT_LIBS = $(GNUTLS_DIR)\bin\libgcrypt-11.lib
GNUTLS_LIBS=\ GNUTLS_LIBS=\
$(GNUTLS_DIR)\bin\libtasn1-3.lib \ $(GNUTLS_DIR)\bin\libtasn1-3.lib \
$(GNUTLS_DIR)\bin\libgpg-error-0.lib \ $(GNUTLS_DIR)\bin\libgpg-error-0.lib \
$(GNUTLS_DIR)\bin\libgcrypt-11.lib \ $(GCRYPT_LIBS) \
$(GNUTLS_DIR)\bin\libgnutls-26.lib $(GNUTLS_DIR)\bin\libgnutls-26.lib
# Nmake uses carets to escape special characters # Nmake uses carets to escape special characters
GNUTLS_CONFIG=^#define HAVE_LIBGNUTLS 1 GNUTLS_CONFIG=^#define HAVE_LIBGNUTLS 1