Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/debug/di/rspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -6397,8 +6397,8 @@ class CordbThread : public CordbBase, public ICorDebugThread,
// Lazily initialized.
EXCEPTION_RECORD * m_pExceptionRecord;

static const CorDebugUserState kInvalidUserState = CorDebugUserState(-1);
CorDebugUserState m_userState; // This is the current state of the
static const int kInvalidUserState = -1;
int m_userState; // This is the current state of the
// thread, at the time that the
// left side synchronized

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ CorDebugUserState CordbThread::GetUserState()
m_userState = pDAC->GetUserState(m_vmThreadToken);
}

return m_userState;
return (CorDebugUserState)m_userState;
}


Expand Down Expand Up @@ -886,7 +886,7 @@ HRESULT CordbThread::CreateStepper(ICorDebugStepper ** ppStepper)
//Returns true if current user state of a thread is USER_WAIT_SLEEP_JOIN
bool CordbThread::IsThreadWaitingOrSleeping()
{
CorDebugUserState userState = m_userState;
int userState = m_userState;
if (userState == kInvalidUserState)
{
//If m_userState is not ready, we'll read from DAC only part of it which
Expand Down
8 changes: 5 additions & 3 deletions src/native/libs/System.Native/pal_networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t address
char name[_POSIX_HOST_NAME_MAX];
result = gethostname((char*)name, _POSIX_HOST_NAME_MAX);

bool includeIPv4Loopback = true;
bool includeIPv6Loopback = true;
bool includeIPv4Loopback;
bool includeIPv6Loopback;
includeIPv4Loopback = true;
includeIPv6Loopback = true;

if (result == 0 && strcasecmp((const char*)address, name) == 0)
{
Expand Down Expand Up @@ -1526,7 +1528,7 @@ int32_t SystemNative_ReceiveSocketError(intptr_t socket, MessageHeader* messageH
#if HAVE_LINUX_ERRQUEUE_H
char buffer[sizeof(struct sock_extended_err) + sizeof(struct sockaddr_storage)];
messageHeader->ControlBufferLen = sizeof(buffer);
messageHeader->ControlBuffer = (void*)buffer;
messageHeader->ControlBuffer = (uint8_t*)buffer;

struct msghdr header;
struct icmphdr icmph;
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Native/pal_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ int32_t SystemNative_ForkAndExecProcess(const char* filename,

if (setCredentials && groupsLength > 0)
{
getGroupsBuffer = malloc(sizeof(uint32_t) * Int32ToSizeT(groupsLength));
getGroupsBuffer = (uint32_t*)(malloc(sizeof(uint32_t) * Int32ToSizeT(groupsLength)));
if (getGroupsBuffer == NULL)
{
success = false;
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Native/pal_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static bool TryConvertSignalCodeToPosixSignal(int signalCode, PosixSignal* posix
return true;

default:
*posixSignal = signalCode;
*posixSignal = (PosixSignal)signalCode;
return false;
}
}
Expand Down
23 changes: 11 additions & 12 deletions src/native/libs/System.Native/pal_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void)

error = pthread_cond_init(&monitor->Condition, &conditionAttributes);

int condAttrDestroyError = pthread_condattr_destroy(&conditionAttributes);
int condAttrDestroyError;
condAttrDestroyError = pthread_condattr_destroy(&conditionAttributes);
assert(condAttrDestroyError == 0);
(void)condAttrDestroyError; // unused in release build
#else
error = pthread_cond_init(&monitor->Condition, NULL);
#endif
Expand Down Expand Up @@ -118,18 +118,17 @@ void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor)
error = pthread_mutex_destroy(&monitor->Mutex);
assert(error == 0);

(void)error; // unused in release build

free(monitor);
}

void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor)
{
assert(monitor != NULL);

int error = pthread_mutex_lock(&monitor->Mutex);
int error;

error = pthread_mutex_lock(&monitor->Mutex);
assert(error == 0);
(void)error; // unused in release build

SetIsLocked(monitor, true);
}
Expand All @@ -140,9 +139,10 @@ void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor)

SetIsLocked(monitor, false);

int error = pthread_mutex_unlock(&monitor->Mutex);
int error;

error = pthread_mutex_unlock(&monitor->Mutex);
assert(error == 0);
(void)error; // unused in release build
}

void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor)
Expand All @@ -151,9 +151,10 @@ void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor)

SetIsLocked(monitor, false);

int error = pthread_cond_wait(&monitor->Condition, &monitor->Mutex);
int error;

error = pthread_cond_wait(&monitor->Condition, &monitor->Mutex);
assert(error == 0);
(void)error; // unused in release build

SetIsLocked(monitor, true);
}
Expand Down Expand Up @@ -213,8 +214,6 @@ void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor)

error = pthread_mutex_unlock(&monitor->Mutex);
assert(error == 0);

(void)error; // unused in release build
}

int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter)
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Net.Security.Native/pal_gssapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ uint32_t NetSecurityNative_ImportPrincipalName(uint32_t* minorStatus,
// Principal name will usually be in the form SERVICE/HOST. But SPNEGO protocol prefers
// GSS_C_NT_HOSTBASED_SERVICE format. That format uses '@' separator instead of '/' between
// service name and host name. So convert input string into that format.
char* ptrSlash = memchr(inputName, '/', inputNameLen);
char* ptrSlash = (char*)memchr(inputName, '/', inputNameLen);
char* inputNameCopy = NULL;
if (ptrSlash != NULL)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void do_track_entry(header_t* entry, int32_t add)

static void* mallocFunction(size_t size, const char *file, int line)
{
header_t* entry = malloc(size + sizeof(header_t));
header_t* entry = (header_t*)malloc(size + sizeof(header_t));
if (entry != NULL)
{
init_memory_entry(entry, size, file, line);
Expand All @@ -187,7 +187,7 @@ static void* reallocFunction (void *ptr, size_t size, const char *file, int line
}

void* toReturn = NULL;
header_t* newEntry = (header_t*) realloc((void*)entry, size + sizeof(header_t));
header_t* newEntry = (header_t*)realloc((void*)entry, size + sizeof(header_t));
if (newEntry != NULL)
{
entry = newEntry;
Expand Down Expand Up @@ -279,7 +279,7 @@ void CryptoNative_ForEachTrackedAllocation(void (*callback)(void* ptr, uint64_t

static void init_tracking_lists(void)
{
g_trackedMemory = malloc(kPartitionCount * sizeof(list_t));
g_trackedMemory = (list_t*)malloc(kPartitionCount * sizeof(list_t));
for (uint32_t i = 0; i < kPartitionCount; i++)
{
list_init(&g_trackedMemory[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ static int32_t EnsureOpenSsl10Initialized(void)
int numLocks = 0;
int locksInitialized = 0;
int randPollResult = 0;
size_t allocationSize = 0;

pthread_mutex_lock(&g_initLock);

Expand All @@ -1390,7 +1391,6 @@ static int32_t EnsureOpenSsl10Initialized(void)
}

// Create the locks array
size_t allocationSize = 0;
if (!multiply_s(sizeof(pthread_mutex_t), (size_t)numLocks, &allocationSize))
{
ret = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,8 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
EC_GROUP* group = NULL;
size_t generatorBufferSize = 0;
unsigned char* generatorBuffer = NULL;
int curveTypeNID;
int fieldTypeNID;

// Exit if CryptoNative_EvpPKeyGetEcKeyParameters failed
if (rc != 1)
Expand All @@ -798,7 +800,6 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
if (!xBn || !yBn)
goto error;

int curveTypeNID;
if (!CryptoNative_EvpPKeyGetEcGroupNid(pkey, &curveTypeNID) || !curveTypeNID)
goto error;

Expand All @@ -819,7 +820,7 @@ int32_t CryptoNative_EvpPKeyGetEcCurveParameters(
// and some providers seem to be ignoring OSSL_PKEY_PARAM_EC_FIELD_TYPE.
// This is specifically true for tpm2 provider.
// We can reliably get the field type from the EC_GROUP.
int fieldTypeNID = EC_GROUP_get_field_type(group);
fieldTypeNID = EC_GROUP_get_field_type(group);

*curveType = NIDToCurveType(fieldTypeNID);
if (*curveType == Unspecified)
Expand Down
90 changes: 47 additions & 43 deletions src/native/libs/System.Security.Cryptography.Native/pal_evp_kdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,26 @@ int32_t CryptoNative_KbkdfHmacOneShot(
goto cleanup;
}

size_t keyLengthT = Int32ToSizeT(keyLength);
size_t destinationLengthT = Int32ToSizeT(destinationLength);
size_t labelLengthT = Int32ToSizeT(labelLength);
size_t contextLengthT = Int32ToSizeT(contextLength);

OSSL_PARAM params[] =
{
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, algorithm, 0),
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, "HMAC", 0),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, (void*)key, keyLengthT),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, (void*)label, labelLengthT),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, (void*)context, contextLengthT),
OSSL_PARAM_construct_end(),
};

if (EVP_KDF_derive(ctx, destination, destinationLengthT, params) <= 0)
{
goto cleanup;
size_t keyLengthT = Int32ToSizeT(keyLength);
size_t destinationLengthT = Int32ToSizeT(destinationLength);
size_t labelLengthT = Int32ToSizeT(labelLength);
size_t contextLengthT = Int32ToSizeT(contextLength);

OSSL_PARAM params[] =
{
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, algorithm, 0),
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, "HMAC", 0),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, (void*)key, keyLengthT),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, (void*)label, labelLengthT),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, (void*)context, contextLengthT),
OSSL_PARAM_construct_end(),
};

if (EVP_KDF_derive(ctx, destination, destinationLengthT, params) <= 0)
{
goto cleanup;
}
}

ret = 1;
Expand Down Expand Up @@ -199,33 +201,35 @@ static int32_t HkdfCore(
goto cleanup;
}

size_t keyLengthT = Int32ToSizeT(keyLength);
size_t destinationLengthT = Int32ToSizeT(destinationLength);

OSSL_PARAM params[6] = {{0}};
int i = 0;
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, (void*)key, keyLengthT);
params[i++] = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, algorithm, 0);

if (salt != NULL && saltLength > 0)
{
size_t saltLengthT = Int32ToSizeT(saltLength);
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, (void*)salt, saltLengthT);
}

if (info != NULL && infoLength > 0)
{
size_t infoLengthT = Int32ToSizeT(infoLength);
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, (void*)info, infoLengthT);
}

params[i++] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &operation);
params[i] = OSSL_PARAM_construct_end();
assert(i < 6);

if (EVP_KDF_derive(ctx, destination, destinationLengthT, params) <= 0)
{
goto cleanup;
size_t keyLengthT = Int32ToSizeT(keyLength);
size_t destinationLengthT = Int32ToSizeT(destinationLength);

OSSL_PARAM params[6] = {{0}};
int i = 0;
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, (void*)key, keyLengthT);
params[i++] = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, algorithm, 0);

if (salt != NULL && saltLength > 0)
{
size_t saltLengthT = Int32ToSizeT(saltLength);
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, (void*)salt, saltLengthT);
}

if (info != NULL && infoLength > 0)
{
size_t infoLengthT = Int32ToSizeT(infoLength);
params[i++] = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, (void*)info, infoLengthT);
}

params[i++] = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &operation);
params[i] = OSSL_PARAM_construct_end();
assert(i < 6);

if (EVP_KDF_derive(ctx, destination, destinationLengthT, params) <= 0)
{
goto cleanup;
}
}

ret = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ int32_t CryptoNative_EvpKemEncapsulate(EVP_PKEY* pKey,
EVP_PKEY_CTX* ctx = NULL;
ctx = EvpPKeyCtxCreateFromPKey(pKey, extraHandle);
int32_t ret = 0;
size_t ciphertextLengthT;
size_t sharedSecretLengthT;

if (ctx == NULL)
{
Expand All @@ -173,8 +175,8 @@ int32_t CryptoNative_EvpKemEncapsulate(EVP_PKEY* pKey,
goto done;
}

size_t ciphertextLengthT = Int32ToSizeT(ciphertextLength);
size_t sharedSecretLengthT = Int32ToSizeT(sharedSecretLength);
ciphertextLengthT = Int32ToSizeT(ciphertextLength);
sharedSecretLengthT = Int32ToSizeT(sharedSecretLength);

if (EVP_PKEY_encapsulate(ctx, ciphertext, &ciphertextLengthT, sharedSecret, &sharedSecretLengthT) != 1)
{
Expand Down Expand Up @@ -228,6 +230,8 @@ int32_t CryptoNative_EvpKemDecapsulate(EVP_PKEY* pKey,
EVP_PKEY_CTX* ctx = NULL;
ctx = EvpPKeyCtxCreateFromPKey(pKey, extraHandle);
int32_t ret = 0;
size_t ciphertextLengthT;
size_t sharedSecretLengthT;

if (ctx == NULL)
{
Expand All @@ -239,8 +243,8 @@ int32_t CryptoNative_EvpKemDecapsulate(EVP_PKEY* pKey,
goto done;
}

size_t ciphertextLengthT = Int32ToSizeT(ciphertextLength);
size_t sharedSecretLengthT = Int32ToSizeT(sharedSecretLength);
ciphertextLengthT = Int32ToSizeT(ciphertextLength);
sharedSecretLengthT = Int32ToSizeT(sharedSecretLength);

if (EVP_PKEY_decapsulate(ctx, sharedSecret, &sharedSecretLengthT, ciphertext, ciphertextLengthT) != 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ int32_t CryptoNative_EvpMacOneShot(EVP_MAC* mac,

OSSL_PARAM params[5] = {{0}};
int i = 0;
int32_t ret = 0;
size_t written = 0;

params[i++] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (void*)key, keyLengthT);
params[i++] = OSSL_PARAM_construct_int32(OSSL_MAC_PARAM_SIZE, &destinationLength);
Expand All @@ -369,8 +371,6 @@ int32_t CryptoNative_EvpMacOneShot(EVP_MAC* mac,

params[i] = OSSL_PARAM_construct_end();

int32_t ret = 0;

if (!EVP_MAC_init(ctx, NULL, 0, params))
{
goto done;
Expand All @@ -381,8 +381,6 @@ int32_t CryptoNative_EvpMacOneShot(EVP_MAC* mac,
goto done;
}

size_t written = 0;

if (!EVP_MAC_final(ctx, destination, &written, macLengthT))
{
goto done;
Expand Down
Loading
Loading