From: Michael R Sweet Date: Fri, 1 Oct 2021 13:57:45 +0000 (-0400) Subject: Fix Windows build errors. X-Git-Tag: v2.4b1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ffa55a93f3f5560c96e4cf6087dcd339ab7d98d;p=thirdparty%2Fcups.git Fix Windows build errors. --- diff --git a/cups/hash.c b/cups/hash.c index 310c8d5c7b..103b14b9c2 100644 --- a/cups/hash.c +++ b/cups/hash.c @@ -12,11 +12,15 @@ */ #include "cups-private.h" +#include "debug-internal.h" #ifdef __APPLE__ # include #elif defined(HAVE_GNUTLS) # include # include "md5-internal.h" +#elif _WIN32 +# include +# include #else # include "md5-internal.h" #endif /* __APPLE__ */ @@ -302,10 +306,10 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */ if (algid) { - if (hashsize < hashlen) + if (hashsize < (size_t)hashlen) goto too_small; - if ((status = BCryptOpenAlgorithmProvider(&alg, algid, NULL, 0)) != STATUS_SUCCESS) + if ((status = BCryptOpenAlgorithmProvider(&alg, algid, NULL, 0)) < 0) { DEBUG_printf(("2cupsHashData: BCryptOpenAlgorithmProvider returned %d.", status)); @@ -320,18 +324,18 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */ if (tempsize > 0) { // Do a truncated SHA2-512 hash... - status = BCryptHash(alg, NULL, 0, data, (ULONG)datalen, temp, sizeof(temp)); + status = BCryptHash(alg, NULL, 0, (PUCHAR)data, (ULONG)datalen, temp, sizeof(temp)); memcpy(hash, temp, hashlen); } else { // Hash directly to buffer... - status = BCryptHash(alg, NULL, 0, data, (ULONG)datalen, hash, hashlen); + status = BCryptHash(alg, NULL, 0, (PUCHAR)data, (ULONG)datalen, hash, (ULONG)hashlen); } - BCryptCloseAlgorithmProvider(alg); + BCryptCloseAlgorithmProvider(alg, 0); - if (status != STATUS_SUCCESS) + if (status < 0) { DEBUG_printf(("2cupsHashData: BCryptHash returned %d.", status)); diff --git a/vcnet/libcups2.vcxproj b/vcnet/libcups2.vcxproj index 2dbe057297..e390be0080 100644 --- a/vcnet/libcups2.vcxproj +++ b/vcnet/libcups2.vcxproj @@ -68,7 +68,7 @@ ProgramDatabase - ws2_32.lib;advapi32.lib;%(AdditionalDependencies) + bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies) $(OutDir)libcups2.dll ..\cups\libcups2.def true @@ -92,7 +92,7 @@ ProgramDatabase - ws2_32.lib;advapi32.lib;%(AdditionalDependencies) + bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies) $(OutDir)libcups2.dll ..\cups\libcups2.def true