From: Francesco Chemolli Date: Tue, 23 Oct 2018 19:16:37 +0000 (+0000) Subject: Fix several windows build issues (#309) X-Git-Tag: M-staged-PR311~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee2444645dd6cacc2985fba2c4d37a49422e341a;p=thirdparty%2Fsquid.git Fix several windows build issues (#309) 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 --- diff --git a/lib/sspwin32.cc b/lib/sspwin32.cc index d39ebfd696..aa4e171354 100644 --- a/lib/sspwin32.cc +++ b/lib/sspwin32.cc @@ -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(xcalloc(cbMaxToken, sizeof(char))); + pServerBuf = static_cast(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(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(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(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)); diff --git a/src/acl/external/session/ext_session_acl.cc b/src/acl/external/session/ext_session_acl.cc index 64ffb60e42..b810d66eb3 100644 --- a/src/acl/external/session/ext_session_acl.cc +++ b/src/acl/external/session/ext_session_acl.cc @@ -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 diff --git a/src/anyp/Uri.cc b/src/anyp/Uri.cc index c8249307d4..59a762678c 100644 --- a/src/anyp/Uri.cc +++ b/src/anyp/Uri.cc @@ -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; diff --git a/src/anyp/Uri.h b/src/anyp/Uri.h index 67f0af59f6..e6f252ac94 100644 --- a/src/anyp/Uri.h +++ b/src/anyp/Uri.h @@ -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); diff --git a/src/base/File.cc b/src/base/File.cc index 5d582555c4..2f9ab6181e 100644 --- a/src/base/File.cc +++ b/src/base/File.cc @@ -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_ */ diff --git a/src/base/File.h b/src/base/File.h index d4d7263ebe..7f4c30e669 100644 --- a/src/base/File.h +++ b/src/base/File.h @@ -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;