From d3847ea45933451256d4f693f4f3e09fd1bbd50f Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Tue, 19 Mar 2019 22:32:36 +1100 Subject: [PATCH] Fix VS2010 build: Microsoft specific bool type is predefined. Intermingled declarations and code is not allowed. --- lib/compat.h | 2 +- lib/zip_crypto_win.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/compat.h b/lib/compat.h index 14559e5..af8a900 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -58,7 +58,7 @@ #ifdef HAVE_STDBOOL_H #include -#else +#elif !defined(__BOOL_DEFINED) typedef char bool; #define true 1 #define false 0 diff --git a/lib/zip_crypto_win.c b/lib/zip_crypto_win.c index a596540..556de33 100644 --- a/lib/zip_crypto_win.c +++ b/lib/zip_crypto_win.c @@ -88,12 +88,13 @@ There is no #ifdef to control that, because this is working for all supported OS bool _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length) { BCRYPT_ALG_HANDLE hAlgorithm = NULL; + bool result; if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG))) { return false; } - bool result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0)); + result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0)); BCryptCloseAlgorithmProvider(hAlgorithm, 0);