]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix several windows build issues (#309)
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 23 Oct 2018 19:16:37 +0000 (19:16 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 23 Oct 2018 19:16:41 +0000 (19:16 +0000)
The mingw build has rotten somewhat, there are some type errors
and data access errors.
The fix is not yet complete, but it's a step forward

lib/sspwin32.cc
src/acl/external/session/ext_session_acl.cc
src/anyp/Uri.cc
src/anyp/Uri.h
src/base/File.cc
src/base/File.h

index d39ebfd696b618d462938cf35c54bbfb7fd92233..aa4e171354ccc49c9349358391f0991fcad841fd 100644 (file)
@@ -31,8 +31,8 @@ static char * SSP_Package_InUse;
 SECURITY_STATUS SecurityStatus = SEC_E_OK;
 
 static DWORD cbMaxToken = 0;
-static PVOID pClientBuf = NULL;
-static PVOID pServerBuf = NULL;
+static uint8_t * pClientBuf = NULL;
+static uint8_t * pServerBuf = NULL;
 
 static AUTH_SEQ NTLM_asServer = {0};
 
@@ -200,8 +200,8 @@ HMODULE LoadSecurityDll(int mode, const char * SSP_Package)
     _FreeContextBuffer(pSPI);
 
     /* Allocate buffers for client and server messages */
-    pClientBuf = xcalloc(cbMaxToken, sizeof(char));
-    pServerBuf = xcalloc(cbMaxToken, sizeof(char));
+    pClientBuf = static_cast<uint8_t *>(xcalloc(cbMaxToken, sizeof(char)));
+    pServerBuf = static_cast<uint8_t *>(xcalloc(cbMaxToken, sizeof(char)));
     SSP_Package_InUse = xstrdup(SSP_Package);
 
     return hModule;
@@ -458,7 +458,7 @@ BOOL WINAPI SSP_LogonUser(PTSTR szUser, PTSTR szPassword, PTSTR szDomain)
 const char * WINAPI SSP_MakeChallenge(PVOID PNegotiateBuf, int NegotiateLen)
 {
     BOOL        fDone      = FALSE;
-    PVOID       fResult    = NULL;
+    uint8_t  * fResult = NULL;
     DWORD       cbOut      = 0;
     DWORD       cbIn       = 0;
     ntlm_challenge * challenge;
@@ -491,8 +491,8 @@ const char * WINAPI SSP_MakeChallenge(PVOID PNegotiateBuf, int NegotiateLen)
         NTLM_LocalCall = NTLM_NEGOTIATE_THIS_IS_LOCAL_CALL & challenge->flags;
         struct base64_encode_ctx ctx;
         base64_encode_init(&ctx);
-        static uint8_t encoded[8192];
-        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(fResult));
+        static char encoded[8192];
+        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, fResult);
         assert(dstLen < sizeof(encoded));
         dstLen += base64_encode_final(&ctx, encoded+dstLen);
         assert(dstLen < sizeof(encoded));
@@ -557,8 +557,8 @@ const char * WINAPI SSP_MakeNegotiateBlob(PVOID PNegotiateBuf, int NegotiateLen,
     if (pServerBuf != NULL && cbOut > 0) {
         struct base64_encode_ctx ctx;
         base64_encode_init(&ctx);
-        static uint8_t encoded[8192];
-        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(pServerBuf));
+        static char encoded[8192];
+        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, pServerBuf);
         assert(dstLen < sizeof(encoded));
         dstLen += base64_encode_final(&ctx, encoded+dstLen);
         assert(dstLen < sizeof(encoded));
@@ -592,8 +592,8 @@ const char * WINAPI SSP_ValidateNegotiateCredentials(PVOID PAutenticateBuf, int
     if (pServerBuf != NULL && cbOut > 0) {
         struct base64_encode_ctx ctx;
         base64_encode_init(&ctx);
-        static uint8_t encoded[8192];
-        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(pServerBuf));
+        static char encoded[8192];
+        size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, pServerBuf);
         assert(dstLen < sizeof(encoded));
         dstLen += base64_encode_final(&ctx, encoded+dstLen);
         assert(dstLen < sizeof(encoded));
index 64ffb60e42a0e7b4b467f08cba0cbd561a837460..b810d66eb3e0d04056aea0d5eead327c58c63c66 100644 (file)
@@ -72,6 +72,8 @@ typedef DBT DB_ENTRY;
 TDB_CONTEXT *db = nullptr;
 typedef TDB_DATA DB_ENTRY;
 
+#else
+#error "Either Berkley DB or Trivial DB must be available"
 #endif
 
 static void
index c8249307d41b152d255f197346a813aacd0855f2..59a762678c9b7054123d4cb7e370f3e6d554d096 100644 (file)
@@ -657,7 +657,7 @@ urlMakeAbsolute(const HttpRequest * req, const char *relUrl)
 }
 
 int
-matchDomainName(const char *h, const char *d, uint flags)
+matchDomainName(const char *h, const char *d, uint8_t flags)
 {
     int dl;
     int hl;
index 67f0af59f61b75b02c0d08f6adffedcc4db4a52e..e6f252ac946ee2753b22f6931ccb057db01ecf80 100644 (file)
@@ -231,7 +231,7 @@ enum MatchDomainNameFlags {
  * \retval 1 means the host is greater than the domain
  * \retval -1 means the host is less than the domain
  */
-int matchDomainName(const char *host, const char *domain, uint flags = mdnNone);
+int matchDomainName(const char *host, const char *domain, uint8_t flags = mdnNone);
 int urlCheckRequest(const HttpRequest *);
 char *urlHostname(const char *url);
 void urlExtMethodConfigure(void);
index 5d582555c4e46fa76d14a814d86f5d2bbd168e02..2f9ab6181e03bdc2bb5c7575a27a36102687ba0f 100644 (file)
@@ -170,7 +170,7 @@ void
 File::open(const FileOpeningConfig &cfg)
 {
 #if _SQUID_WINDOWS_
-    fd_ = CreateFile(TEXT(name_.c_str()), desiredAccess, shareMode, nullptr, creationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr);
+    fd_ = CreateFile(TEXT(name_.c_str()), cfg.desiredAccess, cfg.shareMode, nullptr, cfg.creationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr);
     if (fd_ == InvalidHandle) {
         const auto savedError = GetLastError();
         throw TexcHere(sysCallFailure("CreateFile", WindowsErrorMessage(savedError).c_str()));
@@ -199,7 +199,7 @@ File::close()
 #if _SQUID_WINDOWS_
     if (!CloseHandle(fd_)) {
         const auto savedError = GetLastError();
-        debugs(54, DBG_IMPORTANT, sysCallFailure("CloseHandle", WindowsErrorMessage(savedError)));
+        debugs(54, DBG_IMPORTANT, sysCallFailure("CloseHandle", WindowsErrorMessage(savedError).c_str()));
     }
 #else
     if (::close(fd_) != 0) {
@@ -370,3 +370,6 @@ File::sysCallError(const char *callName, const int savedErrno) const
     return sysCallFailure(callName, xstrerr(savedErrno));
 }
 
+#if _SQUID_WINDOWS_
+const HANDLE File::InvalidHandle = INVALID_HANDLE_VALUE;
+#endif /* _SQUID_WINDOWS_ */
index d4d7263ebea1fa5924edab7c190083ad1ebba9c3..7f4c30e6697d85cfe98a51f07268851d34318e85 100644 (file)
@@ -115,7 +115,7 @@ private:
     // Windows-specific HANDLE is needed because LockFileEx() does not take POSIX FDs.
 #if _SQUID_WINDOWS_
     typedef HANDLE Handle;
-    static const Handle InvalidHandle = INVALID_HANDLE_VALUE;
+    static const Handle InvalidHandle;
 #else
     typedef int Handle;
     static const Handle InvalidHandle = -1;