]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix Windows build errors.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 1 Oct 2021 13:57:45 +0000 (09:57 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 1 Oct 2021 13:57:45 +0000 (09:57 -0400)
cups/hash.c
vcnet/libcups2.vcxproj

index 310c8d5c7b0b6fc6c90dd53f002639404b68fe3e..103b14b9c233f9c47c583c7081e2e0ccc8d79267 100644 (file)
  */
 
 #include "cups-private.h"
+#include "debug-internal.h"
 #ifdef __APPLE__
 #  include <CommonCrypto/CommonDigest.h>
 #elif defined(HAVE_GNUTLS)
 #  include <gnutls/crypto.h>
 #  include "md5-internal.h"
+#elif _WIN32
+#  include <windows.h>
+#  include <bcrypt.h>
 #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));
 
index 2dbe0572973e1bf1a78c0a83e8c63ea198205eb1..e390be0080668dee5173062644fe5b868fa425c9 100644 (file)
@@ -68,7 +68,7 @@
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)libcups2.dll</OutputFile>
       <ModuleDefinitionFile>..\cups\libcups2.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -92,7 +92,7 @@
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)libcups2.dll</OutputFile>
       <ModuleDefinitionFile>..\cups\libcups2.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>