You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@@ -120,16 +120,6 @@ c_static_assert(PAL_SEEK_SET == SEEK_SET);
|
||||
c_static_assert(PAL_SEEK_CUR == SEEK_CUR);
|
||||
c_static_assert(PAL_SEEK_END == SEEK_END);
|
||||
|
||||
// Validate our FileAdvice enum values are correct for the platform
|
||||
#if HAVE_POSIX_ADVISE
|
||||
c_static_assert(PAL_POSIX_FADV_NORMAL == POSIX_FADV_NORMAL);
|
||||
c_static_assert(PAL_POSIX_FADV_RANDOM == POSIX_FADV_RANDOM);
|
||||
c_static_assert(PAL_POSIX_FADV_SEQUENTIAL == POSIX_FADV_SEQUENTIAL);
|
||||
c_static_assert(PAL_POSIX_FADV_WILLNEED == POSIX_FADV_WILLNEED);
|
||||
c_static_assert(PAL_POSIX_FADV_DONTNEED == POSIX_FADV_DONTNEED);
|
||||
c_static_assert(PAL_POSIX_FADV_NOREUSE == POSIX_FADV_NOREUSE);
|
||||
#endif
|
||||
|
||||
// Validate our NotifyEvents enum values are correct for the platform
|
||||
#if HAVE_INOTIFY
|
||||
c_static_assert(PAL_IN_ACCESS == IN_ACCESS);
|
||||
@@ -1074,6 +1064,18 @@ int32_t SystemNative_Poll(struct PollEvent* pollEvents, uint32_t eventCount, int
|
||||
int32_t SystemNative_PosixFAdvise(intptr_t fd, int64_t offset, int64_t length, int32_t advice)
|
||||
{
|
||||
#if HAVE_POSIX_ADVISE
|
||||
// POSIX_FADV_* may be different on each platform. Convert the values from PAL to the system's.
|
||||
int32_t actualAdvice;
|
||||
switch (advice)
|
||||
{
|
||||
case PAL_POSIX_FADV_NORMAL: actualAdvice = POSIX_FADV_NORMAL; break;
|
||||
case PAL_POSIX_FADV_RANDOM: actualAdvice = POSIX_FADV_RANDOM; break;
|
||||
case PAL_POSIX_FADV_SEQUENTIAL: actualAdvice = POSIX_FADV_SEQUENTIAL; break;
|
||||
case PAL_POSIX_FADV_WILLNEED: actualAdvice = POSIX_FADV_WILLNEED; break;
|
||||
case PAL_POSIX_FADV_DONTNEED: actualAdvice = POSIX_FADV_DONTNEED; break;
|
||||
case PAL_POSIX_FADV_NOREUSE: actualAdvice = POSIX_FADV_NOREUSE; break;
|
||||
default: return EINVAL; // According to the man page
|
||||
}
|
||||
int32_t result;
|
||||
while ((
|
||||
result =
|
||||
@@ -1085,7 +1087,7 @@ int32_t SystemNative_PosixFAdvise(intptr_t fd, int64_t offset, int64_t length, i
|
||||
ToFileDescriptor(fd),
|
||||
(off_t)offset,
|
||||
(off_t)length,
|
||||
advice)) < 0 && errno == EINTR);
|
||||
actualAdvice)) < 0 && errno == EINTR);
|
||||
return result;
|
||||
#else
|
||||
// Not supported on this platform. Caller can ignore this failure since it's just a hint.
|
||||
|
||||
@@ -764,6 +764,7 @@ static void ConvertMessageHeaderToMsghdr(struct msghdr* header, const struct Mes
|
||||
header->msg_iovlen = (__typeof__(header->msg_iovlen))iovlen;
|
||||
header->msg_control = messageHeader->ControlBuffer;
|
||||
header->msg_controllen = (uint32_t)messageHeader->ControlBufferLen;
|
||||
header->msg_flags = 0;
|
||||
}
|
||||
|
||||
int32_t SystemNative_GetControlMessageBufferSize(int32_t isIPv4, int32_t isIPv6)
|
||||
@@ -1221,7 +1222,7 @@ int32_t SystemNative_ReceiveMessage(intptr_t socket, struct MessageHeader* messa
|
||||
|
||||
assert((int32_t)header.msg_namelen <= messageHeader->SocketAddressLen);
|
||||
messageHeader->SocketAddressLen = Min((int32_t)header.msg_namelen, messageHeader->SocketAddressLen);
|
||||
|
||||
|
||||
assert(header.msg_controllen <= (size_t)messageHeader->ControlBufferLen);
|
||||
messageHeader->ControlBufferLen = Min((int32_t)header.msg_controllen, messageHeader->ControlBufferLen);
|
||||
|
||||
@@ -1257,7 +1258,7 @@ int32_t SystemNative_SendMessage(intptr_t socket, struct MessageHeader* messageH
|
||||
ConvertMessageHeaderToMsghdr(&header, messageHeader, fd);
|
||||
|
||||
ssize_t res;
|
||||
while ((res = sendmsg(fd, &header, flags)) < 0 && errno == EINTR);
|
||||
while ((res = sendmsg(fd, &header, socketFlags)) < 0 && errno == EINTR);
|
||||
if (res != -1)
|
||||
{
|
||||
*sent = res;
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include "pal_ssl.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
// 10.13.4 introduced public API but linking would fail on all prior versions.
|
||||
// For that reason we use function pointers instead of direct call.
|
||||
// This can be revisited after we drop support for 10.12.
|
||||
|
||||
static OSStatus (*SSLSetALPNProtocolsPtr)(SSLContextRef context, CFArrayRef protocols) = NULL;
|
||||
static OSStatus (*SSLCopyALPNProtocolsPtr)(SSLContextRef context, CFArrayRef* protocols) = NULL;
|
||||
// end of ALPN.
|
||||
|
||||
SSLContextRef AppleCryptoNative_SslCreateContext(int32_t isServer)
|
||||
{
|
||||
@@ -60,8 +69,7 @@ int32_t AppleCryptoNative_SslSetMaxProtocolVersion(SSLContextRef sslContext, PAL
|
||||
return SSLSetProtocolVersionMax(sslContext, protocol);
|
||||
}
|
||||
|
||||
int32_t
|
||||
AppleCryptoNative_SslCopyCertChain(SSLContextRef sslContext, SecTrustRef* pChainOut, int32_t* pOSStatus)
|
||||
int32_t AppleCryptoNative_SslCopyCertChain(SSLContextRef sslContext, SecTrustRef* pChainOut, int32_t* pOSStatus)
|
||||
{
|
||||
if (pChainOut != NULL)
|
||||
*pChainOut = NULL;
|
||||
@@ -107,14 +115,12 @@ static int32_t AppleCryptoNative_SslSetSessionOption(SSLContextRef sslContext,
|
||||
return *pOSStatus == noErr;
|
||||
}
|
||||
|
||||
int32_t
|
||||
AppleCryptoNative_SslSetBreakOnServerAuth(SSLContextRef sslContext, int32_t setBreak, int32_t* pOSStatus)
|
||||
int32_t AppleCryptoNative_SslSetBreakOnServerAuth(SSLContextRef sslContext, int32_t setBreak, int32_t* pOSStatus)
|
||||
{
|
||||
return AppleCryptoNative_SslSetSessionOption(sslContext, kSSLSessionOptionBreakOnServerAuth, setBreak, pOSStatus);
|
||||
}
|
||||
|
||||
int32_t
|
||||
AppleCryptoNative_SslSetBreakOnClientAuth(SSLContextRef sslContext, int32_t setBreak, int32_t* pOSStatus)
|
||||
int32_t AppleCryptoNative_SslSetBreakOnClientAuth(SSLContextRef sslContext, int32_t setBreak, int32_t* pOSStatus)
|
||||
{
|
||||
return AppleCryptoNative_SslSetSessionOption(sslContext, kSSLSessionOptionBreakOnClientAuth, setBreak, pOSStatus);
|
||||
}
|
||||
@@ -153,8 +159,52 @@ int32_t AppleCryptoNative_SslSetTargetName(SSLContextRef sslContext,
|
||||
return *pOSStatus == noErr;
|
||||
}
|
||||
|
||||
int32_t
|
||||
AppleCryptoNative_SslSetIoCallbacks(SSLContextRef sslContext, SSLReadFunc readFunc, SSLWriteFunc writeFunc)
|
||||
int32_t AppleCryptoNative_SSLSetALPNProtocols(SSLContextRef sslContext,
|
||||
CFArrayRef protocols,
|
||||
int32_t* pOSStatus)
|
||||
{
|
||||
if (sslContext == NULL || protocols == NULL || pOSStatus == NULL)
|
||||
return -1;
|
||||
|
||||
if (!SSLSetALPNProtocolsPtr)
|
||||
{
|
||||
// not available.
|
||||
*pOSStatus = 0;
|
||||
return 1;
|
||||
}
|
||||
// The underlying call handles NULL inputs, so just pass it through
|
||||
*pOSStatus = (*SSLSetALPNProtocolsPtr)(sslContext, protocols);
|
||||
return *pOSStatus == noErr;
|
||||
}
|
||||
|
||||
int32_t AppleCryptoNative_SslGetAlpnSelected(SSLContextRef sslContext, CFDataRef* protocol)
|
||||
{
|
||||
if (sslContext == NULL || protocol == NULL)
|
||||
return -1;
|
||||
|
||||
*protocol = NULL;
|
||||
if (!SSLCopyALPNProtocolsPtr)
|
||||
{
|
||||
// not available.
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFArrayRef protocols = NULL;
|
||||
OSStatus osStatus = (*SSLCopyALPNProtocolsPtr)(sslContext, &protocols);
|
||||
|
||||
if (osStatus == noErr && protocols != NULL && CFArrayGetCount(protocols) > 0)
|
||||
{
|
||||
*protocol =
|
||||
CFStringCreateExternalRepresentation(NULL, CFArrayGetValueAtIndex(protocols, 0), kCFStringEncodingASCII, 0);
|
||||
}
|
||||
|
||||
if (protocols)
|
||||
CFRelease(protocols);
|
||||
|
||||
return *protocol != NULL;
|
||||
}
|
||||
|
||||
int32_t AppleCryptoNative_SslSetIoCallbacks(SSLContextRef sslContext, SSLReadFunc readFunc, SSLWriteFunc writeFunc)
|
||||
{
|
||||
return SSLSetIOFuncs(sslContext, readFunc, writeFunc);
|
||||
}
|
||||
@@ -214,8 +264,7 @@ AppleCryptoNative_SslWrite(SSLContextRef sslContext, const uint8_t* buf, uint32_
|
||||
return PAL_TlsIo_Success;
|
||||
}
|
||||
|
||||
PAL_TlsIo
|
||||
AppleCryptoNative_SslRead(SSLContextRef sslContext, uint8_t* buf, uint32_t bufLen, uint32_t* written)
|
||||
PAL_TlsIo AppleCryptoNative_SslRead(SSLContextRef sslContext, uint8_t* buf, uint32_t bufLen, uint32_t* written)
|
||||
{
|
||||
if (written == NULL)
|
||||
return PAL_TlsIo_Unknown;
|
||||
@@ -249,8 +298,7 @@ AppleCryptoNative_SslRead(SSLContextRef sslContext, uint8_t* buf, uint32_t bufLe
|
||||
return OSStatusToPAL_TlsIo(status);
|
||||
}
|
||||
|
||||
int32_t
|
||||
AppleCryptoNative_SslIsHostnameMatch(SSLContextRef sslContext, CFStringRef cfHostname, CFDateRef notBefore)
|
||||
int32_t AppleCryptoNative_SslIsHostnameMatch(SSLContextRef sslContext, CFStringRef cfHostname, CFDateRef notBefore)
|
||||
{
|
||||
if (sslContext == NULL || notBefore == NULL)
|
||||
return -1;
|
||||
@@ -395,3 +443,9 @@ int32_t AppleCryptoNative_SslGetCipherSuite(SSLContextRef sslContext, uint32_t*
|
||||
|
||||
return SSLGetNegotiatedCipher(sslContext, pCipherSuiteOut);
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void InitializeAppleCryptoSslShim()
|
||||
{
|
||||
SSLSetALPNProtocolsPtr = (OSStatus(*)(SSLContextRef, CFArrayRef))dlsym(RTLD_DEFAULT, "SSLSetALPNProtocols");
|
||||
SSLCopyALPNProtocolsPtr = (OSStatus(*)(SSLContextRef, CFArrayRef*))dlsym(RTLD_DEFAULT, "SSLCopyALPNProtocols");
|
||||
}
|
||||
|
||||
@@ -138,6 +138,21 @@ DLLEXPORT int32_t AppleCryptoNative_SslSetTargetName(SSLContextRef sslContext,
|
||||
int32_t cbTargetName,
|
||||
int32_t* pOSStatus);
|
||||
|
||||
/*
|
||||
Set list of application protocols for ClientHello.
|
||||
|
||||
Returns 1 on success, 0 on failure, other values for invalid state.
|
||||
|
||||
Output:
|
||||
pOSStatus: Receives the value from SSLSetALPNData()
|
||||
*/
|
||||
DLLEXPORT int32_t AppleCryptoNative_SSLSetALPNProtocols(SSLContextRef sslContext, CFArrayRef protocols, int32_t* pOSStatus);
|
||||
|
||||
/*
|
||||
Get negotiated protocol value from ServerHello.
|
||||
*/
|
||||
DLLEXPORT int32_t AppleCryptoNative_SslGetAlpnSelected(SSLContextRef sslContext, CFDataRef *protocol);
|
||||
|
||||
/*
|
||||
Register the callbacks for reading and writing data to the SSL context.
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
#
|
||||
# !!!! IMPORTANT !!!!
|
||||
#
|
||||
# The last reviewed revision: 045ff75053df6ba4e385aeb9bc969494b216f992
|
||||
# The last reviewed revision: b70c466082dfdc30de89808e34097b30e6124b75
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user