Fix errors for building production code on VS2008
This commit is contained in:
Родитель
c45c4d9414
Коммит
43d647e27f
|
@ -27,7 +27,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
set(MACOSX TRUE)
|
set(MACOSX TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include (CTest)
|
include(CTest)
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
|
||||||
#these are the include folders
|
#these are the include folders
|
||||||
#the following "set" statetement exports across the project a global variable called COMMON_INC_FOLDER that expands to whatever needs to included when using COMMON library
|
#the following "set" statetement exports across the project a global variable called COMMON_INC_FOLDER that expands to whatever needs to included when using COMMON library
|
||||||
|
@ -36,9 +37,13 @@ set(SHARED_UTIL_SRC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/src CACHE INTERNAL "this is
|
||||||
set(SHARED_UTIL_ADAPTER_FOLDER "${CMAKE_CURRENT_LIST_DIR}/adapters" CACHE INTERNAL "this is where the adapters live" FORCE)
|
set(SHARED_UTIL_ADAPTER_FOLDER "${CMAKE_CURRENT_LIST_DIR}/adapters" CACHE INTERNAL "this is where the adapters live" FORCE)
|
||||||
|
|
||||||
include_directories(${SHARED_UTIL_INC_FOLDER})
|
include_directories(${SHARED_UTIL_INC_FOLDER})
|
||||||
if (WINCE)
|
|
||||||
include_directories(${SHARED_UTIL_INC_FOLDER}/azure_c_shared_utility/windowsce) #windowsce SDK doesn't have stdbool.h
|
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
|
||||||
ENDIF()
|
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
||||||
|
|
||||||
|
if ((NOT HAVE_STDINT_H) OR (NOT HAVE_STDBOOL_H))
|
||||||
|
include_directories(${SHARED_UTIL_INC_FOLDER}/azure_c_shared_utility/windowsce)
|
||||||
|
endif()
|
||||||
|
|
||||||
#the following variables are project-wide and can be used with cmake-gui
|
#the following variables are project-wide and can be used with cmake-gui
|
||||||
option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF)
|
option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "azure_c_shared_utility/platform.h"
|
#include "azure_c_shared_utility/platform.h"
|
||||||
#include "azure_c_shared_utility/optimize_size.h"
|
#include "azure_c_shared_utility/optimize_size.h"
|
||||||
#include "azure_c_shared_utility/xio.h"
|
#include "azure_c_shared_utility/xio.h"
|
||||||
|
#include "azure_c_shared_utility/strings.h"
|
||||||
#include "winsock2.h"
|
#include "winsock2.h"
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
|
@ -53,11 +54,13 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void)
|
||||||
|
|
||||||
STRING_HANDLE platform_get_platform_info(void)
|
STRING_HANDLE platform_get_platform_info(void)
|
||||||
{
|
{
|
||||||
|
STRING_HANDLE result;
|
||||||
#ifndef WINCE
|
#ifndef WINCE
|
||||||
SYSTEM_INFO sys_info;
|
SYSTEM_INFO sys_info;
|
||||||
|
char *arch;
|
||||||
|
DWORD dwVersion;
|
||||||
GetSystemInfo(&sys_info);
|
GetSystemInfo(&sys_info);
|
||||||
|
|
||||||
char *arch;
|
|
||||||
switch (sys_info.wProcessorArchitecture)
|
switch (sys_info.wProcessorArchitecture)
|
||||||
{
|
{
|
||||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
|
@ -82,11 +85,11 @@ STRING_HANDLE platform_get_platform_info(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning(disable:4996)
|
#pragma warning(disable:4996)
|
||||||
DWORD dwVersion = GetVersion();
|
dwVersion = GetVersion();
|
||||||
#pragma warning(default:4996)
|
#pragma warning(default:4996)
|
||||||
STRING_HANDLE result = STRING_construct_sprintf("(Windows NT %d.%d; %s)", LOBYTE(LOWORD(dwVersion)), HIBYTE(LOWORD(dwVersion)), arch);
|
result = STRING_construct_sprintf("(Windows NT %d.%d; %s)", LOBYTE(LOWORD(dwVersion)), HIBYTE(LOWORD(dwVersion)), arch);
|
||||||
#else
|
#else
|
||||||
STRING_HANDLE result = STRING_construct("(Windows CE)");
|
result = STRING_construct("(Windows CE)");
|
||||||
#endif
|
#endif
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,9 +40,10 @@ UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t len)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
size_t cpyLen;
|
||||||
/* Codes_SRS_UNIQUEID_07_001: [UniqueId_Generate shall create a unique Id 36 character long string.] */
|
/* Codes_SRS_UNIQUEID_07_001: [UniqueId_Generate shall create a unique Id 36 character long string.] */
|
||||||
memset(uid, 0, len);
|
memset(uid, 0, len);
|
||||||
size_t cpyLen = strlen((char*)randomResult);
|
cpyLen = strlen((char*)randomResult);
|
||||||
if (cpyLen > len - 1)
|
if (cpyLen > len - 1)
|
||||||
{
|
{
|
||||||
cpyLen = len - 1;
|
cpyLen = len - 1;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
#ifndef CSTDINT_H
|
||||||
|
#define CSTDINT_H
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
#endif /* CSTDINT_H */
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
#ifndef INTTYPES_H
|
||||||
|
#define INTTYPES_H
|
||||||
|
|
||||||
|
#define PRId8 "hhd"
|
||||||
|
#define PRId16 "hd"
|
||||||
|
#define PRId32 "d"
|
||||||
|
#define PRId64 "lld"
|
||||||
|
|
||||||
|
#define PRIu8 "hhu"
|
||||||
|
#define PRIu16 "hu"
|
||||||
|
#define PRIu32 "u"
|
||||||
|
#define PRIu64 "llu"
|
||||||
|
|
||||||
|
#endif // INTTYPES_H
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
#ifndef STDINT_H
|
||||||
|
#define STDINT_H
|
||||||
|
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef short int16_t;
|
||||||
|
typedef int int32_t;
|
||||||
|
typedef long long int64_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
|
||||||
|
typedef signed char int_least8_t;
|
||||||
|
typedef short int_least16_t;
|
||||||
|
typedef int int_least32_t;
|
||||||
|
typedef long long int_least64_t;
|
||||||
|
typedef unsigned char uint_least8_t;
|
||||||
|
typedef unsigned short uint_least16_t;
|
||||||
|
typedef unsigned int uint_least32_t;
|
||||||
|
typedef unsigned long long uint_least64_t;
|
||||||
|
|
||||||
|
typedef signed char int_fast8_t;
|
||||||
|
typedef int int_fast16_t;
|
||||||
|
typedef int int_fast32_t;
|
||||||
|
typedef long long int_fast64_t;
|
||||||
|
typedef unsigned char uint_fast8_t;
|
||||||
|
typedef unsigned int uint_fast16_t;
|
||||||
|
typedef unsigned int uint_fast32_t;
|
||||||
|
typedef unsigned long long uint_fast64_t;
|
||||||
|
|
||||||
|
#define INT8_MIN (-127i8 - 1)
|
||||||
|
#define INT16_MIN (-32767i16 - 1)
|
||||||
|
#define INT32_MIN (-2147483647i32 - 1)
|
||||||
|
#define INT64_MIN (-9223372036854775807i64 - 1)
|
||||||
|
#define INT8_MAX 127i8
|
||||||
|
#define INT16_MAX 32767i16
|
||||||
|
#define INT32_MAX 2147483647i32
|
||||||
|
#define INT64_MAX 9223372036854775807i64
|
||||||
|
#define UINT8_MAX 0xffui8
|
||||||
|
#define UINT16_MAX 0xffffui16
|
||||||
|
#define UINT32_MAX 0xffffffffui32
|
||||||
|
#define UINT64_MAX 0xffffffffffffffffui64
|
||||||
|
|
||||||
|
#endif /* STDINT_H */
|
|
@ -10,6 +10,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#if defined _MSC_VER
|
||||||
|
#if _MSC_VER <= 1500
|
||||||
|
#pragma warning (disable : 4127)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "azure_c_shared_utility/agenttime.h"
|
#include "azure_c_shared_utility/agenttime.h"
|
||||||
#include "azure_c_shared_utility/optimize_size.h"
|
#include "azure_c_shared_utility/optimize_size.h"
|
||||||
|
|
||||||
|
@ -116,8 +122,8 @@ so we compacted the log in the macro LogInfo.
|
||||||
#define MESSAGE_BUFFER_SIZE 260
|
#define MESSAGE_BUFFER_SIZE 260
|
||||||
#define LogErrorWinHTTPWithGetLastErrorAsString(FORMAT, ...) do { \
|
#define LogErrorWinHTTPWithGetLastErrorAsString(FORMAT, ...) do { \
|
||||||
DWORD errorMessageID = GetLastError(); \
|
DWORD errorMessageID = GetLastError(); \
|
||||||
|
char messageBuffer[MESSAGE_BUFFER_SIZE]; \
|
||||||
LogError(FORMAT, __VA_ARGS__); \
|
LogError(FORMAT, __VA_ARGS__); \
|
||||||
CHAR messageBuffer[MESSAGE_BUFFER_SIZE]; \
|
|
||||||
if (errorMessageID == 0) \
|
if (errorMessageID == 0) \
|
||||||
{\
|
{\
|
||||||
LogError("GetLastError() returned 0. Make sure you are calling this right after the code that failed. "); \
|
LogError("GetLastError() returned 0. Make sure you are calling this right after the code that failed. "); \
|
||||||
|
|
|
@ -14,11 +14,11 @@ static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
||||||
|
|
||||||
if (open_result == IO_OPEN_OK)
|
if (open_result == IO_OPEN_OK)
|
||||||
{
|
{
|
||||||
(void)printf("Sending bytes ...\r\n");
|
|
||||||
XIO_HANDLE socketio = (XIO_HANDLE)context;
|
XIO_HANDLE socketio = (XIO_HANDLE)context;
|
||||||
const char to_send[] = "GET / HTTP/1.1\r\n"
|
const char to_send[] = "GET / HTTP/1.1\r\n"
|
||||||
"Host: www.google.com\r\n"
|
"Host: www.google.com\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
(void)printf("Sending bytes ...\r\n");
|
||||||
if (xio_send(socketio, to_send, sizeof(to_send), NULL, NULL) != 0)
|
if (xio_send(socketio, to_send, sizeof(to_send), NULL, NULL) != 0)
|
||||||
{
|
{
|
||||||
(void)printf("Send failed\r\n");
|
(void)printf("Send failed\r\n");
|
||||||
|
@ -83,7 +83,8 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (1)
|
unsigned char done = 0;
|
||||||
|
while (!done)
|
||||||
{
|
{
|
||||||
xio_dowork(socketio);
|
xio_dowork(socketio);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
||||||
|
|
||||||
if (open_result == IO_OPEN_OK)
|
if (open_result == IO_OPEN_OK)
|
||||||
{
|
{
|
||||||
(void)printf("Sending bytes ...\r\n");
|
|
||||||
XIO_HANDLE tlsio = (XIO_HANDLE)context;
|
XIO_HANDLE tlsio = (XIO_HANDLE)context;
|
||||||
const char to_send[] = "GET / HTTP/1.1\r\n"
|
const char to_send[] = "GET / HTTP/1.1\r\n"
|
||||||
"Host: www.google.com\r\n"
|
"Host: www.google.com\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
(void)printf("Sending bytes ...\r\n");
|
||||||
if (xio_send(tlsio, to_send, sizeof(to_send), NULL, NULL) != 0)
|
if (xio_send(tlsio, to_send, sizeof(to_send), NULL, NULL) != 0)
|
||||||
{
|
{
|
||||||
(void)printf("Send failed\r\n");
|
(void)printf("Send failed\r\n");
|
||||||
|
@ -81,7 +81,8 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (1)
|
unsigned char done = 0;
|
||||||
|
while (!done)
|
||||||
{
|
{
|
||||||
xio_dowork(tlsio);
|
xio_dowork(tlsio);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@ __attribute__ ((format (printf, 6, 7)))
|
||||||
#endif
|
#endif
|
||||||
void consolelogger_log(LOG_CATEGORY log_category, const char* file, const char* func, const int line, unsigned int options, const char* format, ...)
|
void consolelogger_log(LOG_CATEGORY log_category, const char* file, const char* func, const int line, unsigned int options, const char* format, ...)
|
||||||
{
|
{
|
||||||
|
time_t t;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
||||||
time_t t = time(NULL);
|
t = time(NULL);
|
||||||
|
|
||||||
switch (log_category)
|
switch (log_category)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,8 +14,20 @@
|
||||||
#include "azure_c_shared_utility/optimize_size.h"
|
#include "azure_c_shared_utility/optimize_size.h"
|
||||||
#include "azure_c_shared_utility/crt_abstractions.h"
|
#include "azure_c_shared_utility/crt_abstractions.h"
|
||||||
|
|
||||||
|
// VS 2008 does not have INFINITY and all the nice goodies...
|
||||||
|
#if defined (TIZENRT) || defined (WINCE)
|
||||||
|
#define DEFINE_INFINITY 1
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined _MSC_VER
|
||||||
|
#if _MSC_VER <= 1500
|
||||||
|
#define DEFINE_INFINITY 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined DEFINE_INFINITY
|
||||||
|
|
||||||
#if defined (WINCE) || defined (TIZENRT)
|
|
||||||
#pragma warning(disable:4756) // warning C4756: overflow in constant arithmetic
|
#pragma warning(disable:4756) // warning C4756: overflow in constant arithmetic
|
||||||
|
|
||||||
// These defines are missing in math.h for WEC2013 SDK
|
// These defines are missing in math.h for WEC2013 SDK
|
||||||
|
@ -29,8 +41,6 @@
|
||||||
#define NAN ((float)(INFINITY * 0.0F))
|
#define NAN ((float)(INFINITY * 0.0F))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -137,9 +137,9 @@ MAP_HANDLE Map_Clone(MAP_HANDLE handle)
|
||||||
}
|
}
|
||||||
else if ((result->values = Map_CloneVector((const char* const*)handleData->values, handleData->count)) == NULL)
|
else if ((result->values = Map_CloneVector((const char* const*)handleData->values, handleData->count)) == NULL)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
/*Codes_SRS_MAP_02_047: [If during cloning, any operation fails, then Map_Clone shall return NULL.] */
|
/*Codes_SRS_MAP_02_047: [If during cloning, any operation fails, then Map_Clone shall return NULL.] */
|
||||||
LogError("unable to clone values");
|
LogError("unable to clone values");
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < result->count; i++)
|
for (i = 0; i < result->count; i++)
|
||||||
{
|
{
|
||||||
free(result->keys[i]);
|
free(result->keys[i]);
|
||||||
|
|
|
@ -288,7 +288,11 @@ static void send_client_hello(TLS_IO_INSTANCE* tls_io_instance)
|
||||||
auth_data.dwMinimumCipherStrength = 0;
|
auth_data.dwMinimumCipherStrength = 0;
|
||||||
auth_data.dwMaximumCipherStrength = 0;
|
auth_data.dwMaximumCipherStrength = 0;
|
||||||
auth_data.dwSessionLifespan = 0;
|
auth_data.dwSessionLifespan = 0;
|
||||||
|
#if defined(SCH_USE_STRONG_CRYPTO)
|
||||||
auth_data.dwFlags = SCH_USE_STRONG_CRYPTO | SCH_CRED_NO_DEFAULT_CREDS;
|
auth_data.dwFlags = SCH_USE_STRONG_CRYPTO | SCH_CRED_NO_DEFAULT_CREDS;
|
||||||
|
#else
|
||||||
|
auth_data.dwFlags = SCH_CRED_NO_DEFAULT_CREDS;
|
||||||
|
#endif
|
||||||
auth_data.dwCredFormat = 0;
|
auth_data.dwCredFormat = 0;
|
||||||
|
|
||||||
status = AcquireCredentialsHandle(NULL, UNISP_NAME, SECPKG_CRED_OUTBOUND, NULL,
|
status = AcquireCredentialsHandle(NULL, UNISP_NAME, SECPKG_CRED_OUTBOUND, NULL,
|
||||||
|
@ -300,6 +304,7 @@ static void send_client_hello(TLS_IO_INSTANCE* tls_io_instance)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
SecBufferDesc security_buffers_desc;
|
||||||
tls_io_instance->credential_handle_allocated = true;
|
tls_io_instance->credential_handle_allocated = true;
|
||||||
|
|
||||||
init_security_buffers[0].cbBuffer = 0;
|
init_security_buffers[0].cbBuffer = 0;
|
||||||
|
@ -309,7 +314,6 @@ static void send_client_hello(TLS_IO_INSTANCE* tls_io_instance)
|
||||||
init_security_buffers[1].BufferType = SECBUFFER_EMPTY;
|
init_security_buffers[1].BufferType = SECBUFFER_EMPTY;
|
||||||
init_security_buffers[1].pvBuffer = 0;
|
init_security_buffers[1].pvBuffer = 0;
|
||||||
|
|
||||||
SecBufferDesc security_buffers_desc;
|
|
||||||
security_buffers_desc.cBuffers = 2;
|
security_buffers_desc.cBuffers = 2;
|
||||||
security_buffers_desc.pBuffers = init_security_buffers;
|
security_buffers_desc.pBuffers = init_security_buffers;
|
||||||
security_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
security_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
@ -539,6 +543,10 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
{
|
{
|
||||||
SecBuffer input_buffers[2];
|
SecBuffer input_buffers[2];
|
||||||
SecBuffer output_buffers[2];
|
SecBuffer output_buffers[2];
|
||||||
|
SecBufferDesc input_buffers_desc;
|
||||||
|
SecBufferDesc output_buffers_desc;
|
||||||
|
SECURITY_STATUS status;
|
||||||
|
unsigned long flags;
|
||||||
ULONG context_attributes;
|
ULONG context_attributes;
|
||||||
|
|
||||||
/* we need to try and perform the second (next) step of the init */
|
/* we need to try and perform the second (next) step of the init */
|
||||||
|
@ -549,7 +557,6 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
input_buffers[1].BufferType = SECBUFFER_EMPTY;
|
input_buffers[1].BufferType = SECBUFFER_EMPTY;
|
||||||
input_buffers[1].pvBuffer = 0;
|
input_buffers[1].pvBuffer = 0;
|
||||||
|
|
||||||
SecBufferDesc input_buffers_desc;
|
|
||||||
input_buffers_desc.cBuffers = 2;
|
input_buffers_desc.cBuffers = 2;
|
||||||
input_buffers_desc.pBuffers = input_buffers;
|
input_buffers_desc.pBuffers = input_buffers;
|
||||||
input_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
input_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
@ -561,13 +568,12 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
output_buffers[1].BufferType = SECBUFFER_EMPTY;
|
output_buffers[1].BufferType = SECBUFFER_EMPTY;
|
||||||
output_buffers[1].pvBuffer = 0;
|
output_buffers[1].pvBuffer = 0;
|
||||||
|
|
||||||
SecBufferDesc output_buffers_desc;
|
|
||||||
output_buffers_desc.cBuffers = 2;
|
output_buffers_desc.cBuffers = 2;
|
||||||
output_buffers_desc.pBuffers = output_buffers;
|
output_buffers_desc.pBuffers = output_buffers;
|
||||||
output_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
output_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
|
||||||
unsigned long flags = ISC_REQ_EXTENDED_ERROR | ISC_REQ_STREAM | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_USE_SUPPLIED_CREDS;
|
flags = ISC_REQ_EXTENDED_ERROR | ISC_REQ_STREAM | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_USE_SUPPLIED_CREDS;
|
||||||
SECURITY_STATUS status = InitializeSecurityContext(&tls_io_instance->credential_handle,
|
status = InitializeSecurityContext(&tls_io_instance->credential_handle,
|
||||||
&tls_io_instance->security_context, tls_io_instance->host_name, flags, 0, 0, &input_buffers_desc, 0,
|
&tls_io_instance->security_context, tls_io_instance->host_name, flags, 0, 0, &input_buffers_desc, 0,
|
||||||
&tls_io_instance->security_context, &output_buffers_desc,
|
&tls_io_instance->security_context, &output_buffers_desc,
|
||||||
&context_attributes, NULL);
|
&context_attributes, NULL);
|
||||||
|
@ -629,9 +635,10 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LIST_ITEM_HANDLE first_pending_io;
|
||||||
tls_io_instance->tlsio_state = TLSIO_STATE_OPEN;
|
tls_io_instance->tlsio_state = TLSIO_STATE_OPEN;
|
||||||
|
|
||||||
LIST_ITEM_HANDLE first_pending_io = singlylinkedlist_get_head_item(tls_io_instance->pending_io_list);
|
first_pending_io = singlylinkedlist_get_head_item(tls_io_instance->pending_io_list);
|
||||||
while (first_pending_io != NULL)
|
while (first_pending_io != NULL)
|
||||||
{
|
{
|
||||||
PENDING_SEND* pending_send = (PENDING_SEND*)singlylinkedlist_item_get_value(first_pending_io);
|
PENDING_SEND* pending_send = (PENDING_SEND*)singlylinkedlist_item_get_value(first_pending_io);
|
||||||
|
@ -734,6 +741,7 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
{
|
{
|
||||||
SecBuffer security_buffers[4];
|
SecBuffer security_buffers[4];
|
||||||
SecBufferDesc security_buffers_desc;
|
SecBufferDesc security_buffers_desc;
|
||||||
|
SECURITY_STATUS status;
|
||||||
|
|
||||||
security_buffers[0].BufferType = SECBUFFER_DATA;
|
security_buffers[0].BufferType = SECBUFFER_DATA;
|
||||||
security_buffers[0].pvBuffer = tls_io_instance->received_bytes;
|
security_buffers[0].pvBuffer = tls_io_instance->received_bytes;
|
||||||
|
@ -746,7 +754,7 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
security_buffers_desc.pBuffers = security_buffers;
|
security_buffers_desc.pBuffers = security_buffers;
|
||||||
security_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
security_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
|
||||||
SECURITY_STATUS status = DecryptMessage(&tls_io_instance->security_context, &security_buffers_desc, 0, NULL);
|
status = DecryptMessage(&tls_io_instance->security_context, &security_buffers_desc, 0, NULL);
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case SEC_E_INCOMPLETE_MESSAGE:
|
case SEC_E_INCOMPLETE_MESSAGE:
|
||||||
|
@ -774,6 +782,8 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
/* notify of the received data */
|
/* notify of the received data */
|
||||||
if (tls_io_instance->on_bytes_received != NULL)
|
if (tls_io_instance->on_bytes_received != NULL)
|
||||||
{
|
{
|
||||||
|
@ -782,7 +792,7 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
|
|
||||||
consumed_bytes = tls_io_instance->received_byte_count;
|
consumed_bytes = tls_io_instance->received_byte_count;
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(security_buffers) / sizeof(security_buffers[0]); i++)
|
for (i = 0; i < sizeof(security_buffers) / sizeof(security_buffers[0]); i++)
|
||||||
{
|
{
|
||||||
/* Any extra bytes left over or did we fully consume the receive buffer? */
|
/* Any extra bytes left over or did we fully consume the receive buffer? */
|
||||||
if (security_buffers[i].BufferType == SECBUFFER_EXTRA)
|
if (security_buffers[i].BufferType == SECBUFFER_EXTRA)
|
||||||
|
@ -808,6 +818,9 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
{
|
{
|
||||||
SecBuffer input_buffers[2];
|
SecBuffer input_buffers[2];
|
||||||
SecBuffer output_buffers[2];
|
SecBuffer output_buffers[2];
|
||||||
|
SecBufferDesc input_buffers_desc;
|
||||||
|
SecBufferDesc output_buffers_desc;
|
||||||
|
unsigned long flags;
|
||||||
ULONG context_attributes;
|
ULONG context_attributes;
|
||||||
|
|
||||||
/* we need to try and perform the second (next) step of the init */
|
/* we need to try and perform the second (next) step of the init */
|
||||||
|
@ -818,7 +831,6 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
input_buffers[1].BufferType = SECBUFFER_EMPTY;
|
input_buffers[1].BufferType = SECBUFFER_EMPTY;
|
||||||
input_buffers[1].pvBuffer = 0;
|
input_buffers[1].pvBuffer = 0;
|
||||||
|
|
||||||
SecBufferDesc input_buffers_desc;
|
|
||||||
input_buffers_desc.cBuffers = 2;
|
input_buffers_desc.cBuffers = 2;
|
||||||
input_buffers_desc.pBuffers = input_buffers;
|
input_buffers_desc.pBuffers = input_buffers;
|
||||||
input_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
input_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
@ -830,12 +842,11 @@ static void on_underlying_io_bytes_received(void* context, const unsigned char*
|
||||||
output_buffers[1].BufferType = SECBUFFER_EMPTY;
|
output_buffers[1].BufferType = SECBUFFER_EMPTY;
|
||||||
output_buffers[1].pvBuffer = 0;
|
output_buffers[1].pvBuffer = 0;
|
||||||
|
|
||||||
SecBufferDesc output_buffers_desc;
|
|
||||||
output_buffers_desc.cBuffers = 2;
|
output_buffers_desc.cBuffers = 2;
|
||||||
output_buffers_desc.pBuffers = output_buffers;
|
output_buffers_desc.pBuffers = output_buffers;
|
||||||
output_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
output_buffers_desc.ulVersion = SECBUFFER_VERSION;
|
||||||
|
|
||||||
unsigned long flags = ISC_REQ_EXTENDED_ERROR | ISC_REQ_STREAM | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_USE_SUPPLIED_CREDS;
|
flags = ISC_REQ_EXTENDED_ERROR | ISC_REQ_STREAM | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_USE_SUPPLIED_CREDS;
|
||||||
status = InitializeSecurityContext(&tls_io_instance->credential_handle,
|
status = InitializeSecurityContext(&tls_io_instance->credential_handle,
|
||||||
&tls_io_instance->security_context, tls_io_instance->host_name, flags, 0, 0, &input_buffers_desc, 0,
|
&tls_io_instance->security_context, tls_io_instance->host_name, flags, 0, 0, &input_buffers_desc, 0,
|
||||||
&tls_io_instance->security_context, &output_buffers_desc,
|
&tls_io_instance->security_context, &output_buffers_desc,
|
||||||
|
@ -1051,6 +1062,8 @@ void tlsio_schannel_destroy(CONCRETE_IO_HANDLE tls_io)
|
||||||
if (tls_io != NULL)
|
if (tls_io != NULL)
|
||||||
{
|
{
|
||||||
TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
|
TLS_IO_INSTANCE* tls_io_instance = (TLS_IO_INSTANCE*)tls_io;
|
||||||
|
LIST_ITEM_HANDLE first_pending_io;
|
||||||
|
|
||||||
if (tls_io_instance->credential_handle_allocated)
|
if (tls_io_instance->credential_handle_allocated)
|
||||||
{
|
{
|
||||||
(void)FreeCredentialHandle(&tls_io_instance->credential_handle);
|
(void)FreeCredentialHandle(&tls_io_instance->credential_handle);
|
||||||
|
@ -1080,7 +1093,7 @@ void tlsio_schannel_destroy(CONCRETE_IO_HANDLE tls_io)
|
||||||
xio_destroy(tls_io_instance->socket_io);
|
xio_destroy(tls_io_instance->socket_io);
|
||||||
free(tls_io_instance->host_name);
|
free(tls_io_instance->host_name);
|
||||||
|
|
||||||
LIST_ITEM_HANDLE first_pending_io = singlylinkedlist_get_head_item(tls_io_instance->pending_io_list);
|
first_pending_io = singlylinkedlist_get_head_item(tls_io_instance->pending_io_list);
|
||||||
while (first_pending_io != NULL)
|
while (first_pending_io != NULL)
|
||||||
{
|
{
|
||||||
PENDING_SEND* pending_send = (PENDING_SEND*)singlylinkedlist_item_get_value(first_pending_io);
|
PENDING_SEND* pending_send = (PENDING_SEND*)singlylinkedlist_item_get_value(first_pending_io);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f9f9c619b633dea1e033dd3d66e05599980e6c13
|
Subproject commit 6467c8d3cf20259add7ff4ccaf38d6ec136e6199
|
|
@ -1 +1 @@
|
||||||
Subproject commit 473332efe601c259ae62ae92be0bbc41a436491b
|
Subproject commit decefd46ee59b5a1a07eb430ae1ee1b2000e7ab5
|
|
@ -1 +1 @@
|
||||||
Subproject commit a688a01009a10b7e5de856ab83f15a0b60cbbf02
|
Subproject commit e1e54ae6a6f3ee53323693afc3a7d72e4688fb51
|
Загрузка…
Ссылка в новой задаче