Merge pull request #4323 from akallabeth/scanbuild_fixes

Scanbuild and other warnings fixed
This commit is contained in:
David Fort 2018-01-08 11:16:21 +01:00 committed by GitHub
commit e1cc601963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 275 additions and 337 deletions

58
channels/geometry/client/geometry_main.c Executable file → Normal file
View File

@ -67,12 +67,12 @@ struct _GEOMETRY_PLUGIN
IWTSListener* listener;
GEOMETRY_LISTENER_CALLBACK* listener_callback;
GeometryClientContext *context;
GeometryClientContext* context;
};
typedef struct _GEOMETRY_PLUGIN GEOMETRY_PLUGIN;
static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgndata)
static UINT32 geometry_read_RGNDATA(wStream* s, UINT32 len, FREERDP_RGNDATA* rgndata)
{
UINT32 dwSize, iType;
INT32 right, bottom;
@ -84,13 +84,17 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
}
Stream_Read_UINT32(s, dwSize);
if (dwSize != 32) {
if (dwSize != 32)
{
WLog_ERR(TAG, "invalid RGNDATA dwSize");
return ERROR_INVALID_DATA;
}
Stream_Read_UINT32(s, iType);
if (iType != RDH_RECTANGLE) {
if (iType != RDH_RECTANGLE)
{
WLog_ERR(TAG, "iType %"PRIu32" for RGNDATA is not supported", iType);
return ERROR_UNSUPPORTED_TYPE;
}
@ -101,11 +105,10 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
Stream_Read_INT32(s, rgndata->boundingRect.y);
Stream_Read_INT32(s, right);
Stream_Read_INT32(s, bottom);
rgndata->boundingRect.width = right - rgndata->boundingRect.x;
rgndata->boundingRect.height = bottom - rgndata->boundingRect.y;
len -= 32;
if (len / (4 * 4) < rgndata->nRectCount)
{
WLog_ERR(TAG, "not enough data for region rectangles");
@ -127,7 +130,6 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
Stream_Read_INT32(s, rgndata->rects[i].y);
Stream_Read_INT32(s, right);
Stream_Read_INT32(s, bottom);
rgndata->rects[i].width = right - rgndata->rects[i].x;
rgndata->rects[i].height = bottom - rgndata->rects[i].y;
}
@ -146,11 +148,10 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
UINT32 length, cbGeometryBuffer;
MAPPED_GEOMETRY_PACKET packet;
GEOMETRY_PLUGIN* geometry;
GeometryClientContext *context;
GeometryClientContext* context;
UINT ret;
geometry = (GEOMETRY_PLUGIN*) callback->plugin;
context = (GeometryClientContext *)geometry->iface.pInterface;
context = (GeometryClientContext*)geometry->iface.pInterface;
if (Stream_GetRemainingLength(s) < 4)
{
@ -159,7 +160,8 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
}
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
if (length < 73 || Stream_GetRemainingLength(s) < (length-4))
if (length < 73 || Stream_GetRemainingLength(s) < (length - 4))
{
WLog_ERR(TAG, "invalid packet length");
return ERROR_INVALID_DATA;
@ -170,20 +172,17 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
Stream_Read_UINT32(s, packet.updateType);
Stream_Seek_UINT32(s); /* flags */
Stream_Read_UINT64(s, packet.topLevelId);
Stream_Read_INT32(s, packet.left);
Stream_Read_INT32(s, packet.top);
Stream_Read_INT32(s, packet.right);
Stream_Read_INT32(s, packet.bottom);
Stream_Read_INT32(s, packet.topLevelLeft);
Stream_Read_INT32(s, packet.topLevelTop);
Stream_Read_INT32(s, packet.topLevelRight);
Stream_Read_INT32(s, packet.topLevelBottom);
Stream_Read_UINT32(s, packet.geometryType);
Stream_Read_UINT32(s, cbGeometryBuffer);
if (Stream_GetRemainingLength(s) < cbGeometryBuffer)
{
WLog_ERR(TAG, "invalid packet length");
@ -191,12 +190,16 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
}
ZeroMemory(&packet.geometry, sizeof(packet.geometry));
if (cbGeometryBuffer)
{
ret = geometry_read_RGNDATA(s, cbGeometryBuffer, &packet.geometry);
if (ret != CHANNEL_RC_OK)
return ret;
}
else
ret = CHANNEL_RC_OK;
if (context->MappedGeometryPacket)
ret = context->MappedGeometryPacket(context, &packet);
@ -210,10 +213,9 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT geometry_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
static UINT geometry_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
GEOMETRY_CHANNEL_CALLBACK* callback = (GEOMETRY_CHANNEL_CALLBACK*) pChannelCallback;
return geometry_recv_pdu(callback, data);
}
@ -234,12 +236,11 @@ static UINT geometry_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
IWTSVirtualChannelCallback** ppCallback)
IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
IWTSVirtualChannelCallback** ppCallback)
{
GEOMETRY_CHANNEL_CALLBACK* callback;
GEOMETRY_LISTENER_CALLBACK* listener_callback = (GEOMETRY_LISTENER_CALLBACK*) pListenerCallback;
callback = (GEOMETRY_CHANNEL_CALLBACK*) calloc(1, sizeof(GEOMETRY_CHANNEL_CALLBACK));
if (!callback)
@ -254,9 +255,7 @@ static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCa
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
listener_callback->channel_callback = callback;
*ppCallback = (IWTSVirtualChannelCallback*) callback;
return CHANNEL_RC_OK;
}
@ -269,8 +268,9 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
{
UINT status;
GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*) pPlugin;
geometry->listener_callback = (GEOMETRY_LISTENER_CALLBACK*) calloc(1,
sizeof(GEOMETRY_LISTENER_CALLBACK));
geometry->listener_callback = (GEOMETRY_LISTENER_CALLBACK*) calloc(1, sizeof(GEOMETRY_LISTENER_CALLBACK));
if (!geometry->listener_callback)
{
WLog_ERR(TAG, "calloc failed!");
@ -280,12 +280,9 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
geometry->listener_callback->iface.OnNewChannelConnection = geometry_on_new_channel_connection;
geometry->listener_callback->plugin = pPlugin;
geometry->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, GEOMETRY_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*) geometry->listener_callback, &(geometry->listener));
(IWTSListenerCallback*) geometry->listener_callback, &(geometry->listener));
geometry->listener->pInterface = geometry->iface.pInterface;
return status;
}
@ -324,11 +321,12 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error = CHANNEL_RC_OK;
GEOMETRY_PLUGIN* geometry;
GeometryClientContext* context;
geometry = (GEOMETRY_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "geometry");
if (!geometry)
{
geometry = (GEOMETRY_PLUGIN*) calloc(1, sizeof(GEOMETRY_PLUGIN));
if (!geometry)
{
WLog_ERR(TAG, "calloc failed!");
@ -339,8 +337,8 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
geometry->iface.Connected = NULL;
geometry->iface.Disconnected = NULL;
geometry->iface.Terminated = geometry_plugin_terminated;
context = (GeometryClientContext*) calloc(1, sizeof(GeometryClientContext));
if (!context)
{
WLog_ERR(TAG, "calloc failed!");
@ -349,10 +347,8 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
}
context->handle = (void*) geometry;
geometry->iface.pInterface = (void*) context;
geometry->context = context;
error = pEntryPoints->RegisterPlugin(pEntryPoints, "geometry", (IWTSPlugin*) geometry);
}
else

View File

@ -678,10 +678,8 @@ static UINT smartcard_irp_request(DEVICE* device, IRP* irp)
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
size_t length;
RDPDR_SMARTCARD* device;
SMARTCARD_DEVICE* smartcard;
UINT error = CHANNEL_RC_NO_MEMORY;
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
@ -706,7 +704,6 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
}
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->IrpQueue = MessageQueue_New(NULL);
if (!smartcard->IrpQueue)

View File

@ -777,7 +777,6 @@ static LONG smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
status = ret.ReturnCode;
out_fail:
free(call->szReader);
return status;
@ -836,7 +835,6 @@ static LONG smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
status = ret.ReturnCode;
out_fail:
free(call->szReader);
return status;
@ -867,8 +865,8 @@ static LONG smartcard_Reconnect_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
Reconnect_Return ret;
IRP* irp = operation->irp;
Reconnect_Call* call = operation->call;
status = ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode,
call->dwPreferredProtocols, call->dwInitialization, &ret.dwActiveProtocol);
ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode,
call->dwPreferredProtocols, call->dwInitialization, &ret.dwActiveProtocol);
smartcard_trace_reconnect_return(smartcard, &ret);
if ((status = smartcard_pack_reconnect_return(smartcard, irp->output, &ret)))
@ -1136,7 +1134,6 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
cchReaderLen = SCARD_AUTOALLOCATE;
cbAtrLen = call->cbAtrLen;
ZeroMemory(ret.pbAtr, 32);
status = ret.ReturnCode = SCardStatusW(operation->hCard,
call->fmszReaderNamesIsNULL ? NULL : (LPWSTR) &mszReaderNames,
@ -1152,6 +1149,7 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if (call->cbAtrLen)
ret.cbAtrLen = cbAtrLen;
}
smartcard_trace_status_return(smartcard, &ret, TRUE);
if ((status = smartcard_pack_status_return(smartcard, irp->output, &ret)))
@ -1207,8 +1205,8 @@ static LONG smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
ret.pioRecvPci = call->pioRecvPci;
status = ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
smartcard_trace_transmit_return(smartcard, &ret);
if ((status = smartcard_pack_transmit_return(smartcard, irp->output, &ret)))
@ -1255,9 +1253,9 @@ static LONG smartcard_Control_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if (!ret.pvOutBuffer)
return SCARD_E_NO_MEMORY;
status = ret.ReturnCode = SCardControl(operation->hCard,
call->dwControlCode, call->pvInBuffer, call->cbInBufferSize,
ret.pvOutBuffer, call->cbOutBufferSize, &ret.cbOutBufferSize);
ret.ReturnCode = SCardControl(operation->hCard,
call->dwControlCode, call->pvInBuffer, call->cbInBufferSize,
ret.pvOutBuffer, call->cbOutBufferSize, &ret.cbOutBufferSize);
smartcard_trace_control_return(smartcard, &ret);
if ((status = smartcard_pack_control_return(smartcard, irp->output, &ret)))
@ -1314,8 +1312,8 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
}
cbAttrLen = call->cbAttrLen;
status = ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId,
autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr, &cbAttrLen);
ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId,
autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr, &cbAttrLen);
ret.cbAttrLen = cbAttrLen;
smartcard_trace_get_attrib_return(smartcard, &ret, call->dwAttrId);
@ -1396,7 +1394,6 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
SMARTCARD_OPERATION* operation)
{
LONG status;
BOOL equal;
DWORD i, j, k;
GetStatusChange_Return ret;
LPSCARD_READERSTATEA state = NULL;
@ -1429,21 +1426,15 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
{
for (j = 0; j < call->cReaders; j++)
{
equal = TRUE;
for (k = 0; k < call->rgAtrMasks[i].cbAtr; k++)
{
if ((call->rgAtrMasks[i].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]) !=
(states[j].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]))
{
equal = FALSE;
break;
}
if (equal)
{
states[j].dwEventState |= SCARD_STATE_ATRMATCH;
}
states[j].dwEventState |= SCARD_STATE_ATRMATCH;
}
}
}

View File

@ -2761,7 +2761,7 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
return STATUS_BUFFER_TOO_SMALL;
}
call->rgAtrMasks = (LocateCards_ATRMask*)calloc(call->cAtrs, sizeof(SCARD_ATRMASK));
call->rgAtrMasks = (LocateCards_ATRMask*)calloc(call->cAtrs, sizeof(LocateCards_ATRMask));
if (!call->rgAtrMasks)
{
@ -2789,7 +2789,7 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
if (call->cReaders > 0)
{
call->rgReaderStates = (ReaderStateA*)calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
call->rgReaderStates = (ReaderStateA*)calloc(call->cReaders, sizeof(ReaderStateA));
if (!call->rgReaderStates)
{

View File

@ -489,10 +489,8 @@ static BOOL xf_event_KeyPress(xfContext* xfc, XEvent* event, BOOL app)
static BOOL xf_event_KeyRelease(xfContext* xfc, XEvent* event, BOOL app)
{
XEvent nextEvent;
KeySym keysym;
char str[256];
XLookupString((XKeyEvent*) event, str, sizeof(str), &keysym, NULL);
xf_keyboard_key_release(xfc, event->xkey.keycode, keysym);
return TRUE;
@ -668,10 +666,8 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
if (settings->DynamicResolutionUpdate)
{
int alignedWidth, alignedHeight;
alignedWidth = (xfc->window->width / 2) * 2;
alignedHeight = (xfc->window->height / 2) * 2;
/* ask the server to resize using the display channel */
xf_disp_handle_configureNotify(xfc, alignedWidth, alignedHeight);
}
@ -960,7 +956,7 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
BOOL status = TRUE;
xfAppWindow* appWindow;
xfContext* xfc = (xfContext*) instance->context;
rdpSettings *settings = xfc->context.settings;
rdpSettings* settings = xfc->context.settings;
if (xfc->remote_app)
{
@ -1064,13 +1060,12 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
default:
if (settings->SupportDisplayControl && xfc->xfDisp)
xf_disp_handle_xevent(xfc, event);
break;
}
xf_cliprdr_handle_xevent(xfc, event);
xf_input_handle_event(xfc, event);
XSync(xfc->display, FALSE);
return status;
}

View File

@ -246,10 +246,7 @@ static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
length += 2;
if (length >= 20 + 8 + 8)
{
length += 3 - strlen(arg->Format);
overlong = TRUE;
}
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
printf("%s[:%s]", arg->Name, overlong ? "..." : arg->Format);
@ -776,7 +773,7 @@ static char** freerdp_command_line_parse_comma_separated_values_ex(const char* n
prefix = (nArgs + 1UL) * sizeof(char*);
len = strlen(list);
p = (char**) calloc(len + prefix + 1, sizeof(char));
p = (char**) calloc(len + prefix + 1, sizeof(char*));
if (!p)
return NULL;

View File

@ -2313,7 +2313,6 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE
if (ncrush_move_encoder_windows(ncrush, &(HistoryBuffer[ncrush->HistoryOffset])) < 0)
return -1001;
HistoryPtr = &HistoryBuffer[32768];
ncrush->HistoryPtr = &HistoryBuffer[32768];
ncrush->HistoryOffset = 32768;
PacketAtFront = TRUE;

View File

@ -104,9 +104,7 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data,
INT16 b_val;
BYTE a_val;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
rw = (context->ChromaSubsamplingLevel ? tempWidth : context->width);
ccl = context->ColorLossLevel;
@ -240,7 +238,6 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data,
yplane = context->priv->PlaneBuffers[0] + y * rw;
coplane = context->priv->PlaneBuffers[1] + y * rw;
cgplane = context->priv->PlaneBuffers[2] + y * rw;
CopyMemory(yplane, yplane - rw, rw);
CopyMemory(coplane, coplane - rw, rw);
CopyMemory(cgplane, cgplane - rw, rw);

View File

@ -55,9 +55,7 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context,
__m128i co_val;
__m128i cg_val;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
rw = (context->ChromaSubsamplingLevel > 0 ? tempWidth : context->width);
ccl = context->ColorLossLevel;
@ -330,7 +328,6 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context,
yplane = context->priv->PlaneBuffers[0] + y * rw;
coplane = context->priv->PlaneBuffers[1] + y * rw;
cgplane = context->priv->PlaneBuffers[2] + y * rw;
CopyMemory(yplane, yplane - rw, rw);
CopyMemory(coplane, coplane - rw, rw);
CopyMemory(cgplane, cgplane - rw, rw);

View File

@ -345,10 +345,8 @@ int zgfx_decompress(ZGFX_CONTEXT* zgfx, const BYTE* pSrcData, UINT32 SrcSize, BY
UINT32 segmentSize;
UINT16 segmentNumber;
UINT16 segmentCount;
UINT32 segmentOffset;
UINT32 uncompressedSize;
BYTE* pConcatenated;
segmentOffset = 7;
if (Stream_GetRemainingLength(stream) < 6)
goto fail;

View File

@ -237,15 +237,15 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
{
PVIRTUALCHANNELENTRY entry;
LPSTR pszFileName;
size_t cchFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
const size_t cchBaseFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
LPCSTR pszExtension;
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
pszExtension = PathGetSharedLibraryExtensionA(0);
if (pszName && pszSubsystem && pszType)
{
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(
pszType) + strlen(pszExtension);
const size_t cchFileName = cchBaseFileName + strlen(pszName) + strlen(pszSubsystem) + strlen(
pszType) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
@ -253,11 +253,10 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName,
pszSubsystem, pszType, pszExtension);
cchFileName = strlen(pszFileName);
}
else if (pszName && pszSubsystem)
{
cchFileName += strlen(pszName) + strlen(pszSubsystem) + strlen(pszExtension);
const size_t cchFileName = cchBaseFileName + strlen(pszName) + strlen(pszSubsystem) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
@ -265,11 +264,10 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName,
pszSubsystem, pszExtension);
cchFileName = strlen(pszFileName);
}
else if (pszName)
{
cchFileName += strlen(pszName) + strlen(pszExtension);
const size_t cchFileName = cchBaseFileName + strlen(pszName) + strlen(pszExtension);
pszFileName = (LPSTR) malloc(cchFileName);
if (!pszFileName)
@ -277,7 +275,6 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName,
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName,
pszExtension);
cchFileName = strlen(pszFileName);
}
else
{

View File

@ -430,6 +430,10 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific
#endif
Stream_Read(s, encsig, siglen);
if (siglen < 8)
return FALSE;
/* Last 8 bytes shall be all zero. */
#if defined(CERT_VALIDATE_PADDING)
@ -443,10 +447,9 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific
}
#endif
siglen -= 8;
#if defined(CERT_VALIDATE_RSA)
if (crypto_rsa_public_decrypt(encsig, siglen, TSSK_KEY_LENGTH, tssk_modulus, tssk_exponent,
if (crypto_rsa_public_decrypt(encsig, siglen - 8, TSSK_KEY_LENGTH, tssk_modulus, tssk_exponent,
sig) <= 0)
{
WLog_ERR(TAG, "invalid RSA decrypt");

View File

@ -162,7 +162,7 @@ static int nla_client_init(rdpNla* nla)
if ((!settings->Username) || (!strlen(settings->Username))
|| (((!settings->Password) || (!strlen(settings->Password)))
&& (!settings->RedirectionPassword)))
&& (!settings->RedirectionPassword)))
{
PromptPassword = TRUE;
}
@ -227,14 +227,14 @@ static int nla_client_init(rdpNla* nla)
if (settings->RedirectionPassword && settings->RedirectionPasswordLength > 0)
{
if (sspi_SetAuthIdentityWithUnicodePassword(nla->identity, settings->Username, settings->Domain,
(UINT16*) settings->RedirectionPassword,
settings->RedirectionPasswordLength / sizeof(WCHAR) - 1) < 0)
(UINT16*) settings->RedirectionPassword,
settings->RedirectionPasswordLength / sizeof(WCHAR) - 1) < 0)
return -1;
}
else
{
if (sspi_SetAuthIdentity(nla->identity, settings->Username, settings->Domain,
settings->Password) < 0)
settings->Password) < 0)
return -1;
}
}
@ -1021,7 +1021,7 @@ static void ap_integer_decrement_le(BYTE* number, int size)
SECURITY_STATUS nla_encrypt_public_key_echo(rdpNla* nla)
{
SecBuffer Buffers[2] = { 0 };
SecBuffer Buffers[2] = { { 0 } };
SecBufferDesc Message;
SECURITY_STATUS status;
int public_key_length;
@ -1079,7 +1079,7 @@ SECURITY_STATUS nla_decrypt_public_key_echo(rdpNla* nla)
BYTE* public_key2 = NULL;
int public_key_length = 0;
int signature_length;
SecBuffer Buffers[2] = { 0 };
SecBuffer Buffers[2] = { { 0 } };
SecBufferDesc Message;
SECURITY_STATUS status;
signature_length = nla->pubKeyAuth.cbBuffer - nla->PublicKey.cbBuffer;
@ -1425,7 +1425,7 @@ static BOOL nla_encode_ts_credentials(rdpNla* nla)
static SECURITY_STATUS nla_encrypt_ts_credentials(rdpNla* nla)
{
SecBuffer Buffers[2] = { 0 };
SecBuffer Buffers[2] = { { 0 } };
SecBufferDesc Message;
SECURITY_STATUS status;
@ -1479,7 +1479,7 @@ static SECURITY_STATUS nla_decrypt_ts_credentials(rdpNla* nla)
int length;
BYTE* buffer;
ULONG pfQOP;
SecBuffer Buffers[2] = { 0 };
SecBuffer Buffers[2] = { { 0 } };
SecBufferDesc Message;
SECURITY_STATUS status;

View File

@ -93,10 +93,6 @@
*
*/
static const BYTE rop_P = 0xF0; /* 11110000 */
static const BYTE rop_S = 0xCC; /* 11001100 */
static const BYTE rop_D = 0xAA; /* 10101010 */
static char* gdi_convert_postfix_to_infix(const char* postfix)
{
int i;

View File

@ -830,7 +830,13 @@ static INLINE pstatus_t general_RGBToAVC444YUV_BGRX(
*/
UINT32 x, y, n, numRows, numCols;
BOOL evenRow = TRUE;
BYTE* b1, *b2, *b3, *b4, *b5, *b6, *b7;
BYTE* b1 = NULL;
BYTE* b2 = NULL;
BYTE* b3 = NULL;
BYTE* b4 = NULL;
BYTE* b5 = NULL;
BYTE* b6 = NULL;
BYTE* b7 = NULL;
const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep;
numRows = (roi->height + 1) & ~1;
numCols = (roi->width + 1) & ~1;
@ -965,7 +971,13 @@ static INLINE pstatus_t general_RGBToAVC444YUV_ANY(
const UINT32 bpp = GetBytesPerPixel(srcFormat);
UINT32 x, y, n, numRows, numCols;
BOOL evenRow = TRUE;
BYTE* b1, *b2, *b3, *b4, *b5, *b6, *b7;
BYTE* b1 = NULL;
BYTE* b2 = NULL;
BYTE* b3 = NULL;
BYTE* b4 = NULL;
BYTE* b5 = NULL;
BYTE* b6 = NULL;
BYTE* b7 = NULL;
const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep;
numRows = (roi->height + 1) & ~1;
numCols = (roi->width + 1) & ~1;

View File

@ -30,11 +30,7 @@ int rdtk_image_copy_alpha_blend(BYTE* pDstData, int nDstStep, int nXDst, int nYD
int nWidth, int nHeight, BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc)
{
int x, y;
int nSrcPad;
int nDstPad;
BYTE A, R, G, B;
nSrcPad = (nSrcStep - (nWidth * 4));
nDstPad = (nDstStep - (nWidth * 4));
for (y = 0; y < nHeight; y++)
{
@ -268,7 +264,7 @@ int rdtk_nine_patch_set_image(rdtkNinePatch* ninePatch, wImage* image)
}
}
pixel = (UINT32*) &((BYTE*) pixel)[scanline];
pixel = (UINT32*) & ((BYTE*) pixel)[scanline];
}
ninePatch->scaleTop = beg - 1;
@ -323,7 +319,7 @@ int rdtk_nine_patch_set_image(rdtkNinePatch* ninePatch, wImage* image)
}
}
pixel = (UINT32*) &((BYTE*) pixel)[scanline];
pixel = (UINT32*) & ((BYTE*) pixel)[scanline];
}
ninePatch->fillTop = beg - 1;

View File

@ -80,7 +80,7 @@ PTP_CLEANUP_GROUP winpr_CreateThreadpoolCleanupGroup(void)
}
VOID winpr_SetThreadpoolCallbackCleanupGroup(PTP_CALLBACK_ENVIRON pcbe, PTP_CLEANUP_GROUP ptpcg,
PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng)
PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng)
{
pcbe->CleanupGroup = ptpcg;
pcbe->CleanupGroupCancelCallback = pfng;
@ -128,7 +128,9 @@ VOID winpr_CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg)
if (ptpcg && ptpcg->groups)
ArrayList_Free(ptpcg->groups);
ptpcg->env->CleanupGroup = NULL;
if (ptpcg && ptpcg->env)
ptpcg->env->CleanupGroup = NULL;
free(ptpcg);
#endif
}

View File

@ -58,7 +58,7 @@ static BOOL test2(void)
int index;
PTP_POOL pool;
PTP_WORK work;
PTP_CLEANUP_GROUP cleanupGroup;
PTP_CLEANUP_GROUP cleanupGroup = NULL;
TP_CALLBACK_ENVIRON environment;
printf("Private Thread Pool\n");

View File

@ -340,7 +340,6 @@ int ntlm_construct_challenge_target_info(NTLM_CONTEXT* context)
int length;
ULONG AvPairsCount;
ULONG AvPairsLength;
LONG AvPairListSize;
NTLM_AV_PAIR* pAvPairList;
UNICODE_STRING NbDomainName;
UNICODE_STRING NbComputerName;
@ -375,7 +374,6 @@ int ntlm_construct_challenge_target_info(NTLM_CONTEXT* context)
return -1;
pAvPairList = (NTLM_AV_PAIR*) context->ChallengeTargetInfo.pvBuffer;
AvPairListSize = (ULONG) context->ChallengeTargetInfo.cbBuffer;
ntlm_av_pair_list_init(pAvPairList);
ntlm_av_pair_add(pAvPairList, MsvAvNbDomainName, (PBYTE) NbDomainName.Buffer, NbDomainName.Length);
ntlm_av_pair_add(pAvPairList, MsvAvNbComputerName, (PBYTE) NbComputerName.Buffer,

View File

@ -38,10 +38,14 @@
const char LM_MAGIC[] = "KGS!@#$%";
static const char NTLM_CLIENT_SIGN_MAGIC[] = "session key to client-to-server signing key magic constant";
static const char NTLM_SERVER_SIGN_MAGIC[] = "session key to server-to-client signing key magic constant";
static const char NTLM_CLIENT_SEAL_MAGIC[] = "session key to client-to-server sealing key magic constant";
static const char NTLM_SERVER_SEAL_MAGIC[] = "session key to server-to-client sealing key magic constant";
static const char NTLM_CLIENT_SIGN_MAGIC[] =
"session key to client-to-server signing key magic constant";
static const char NTLM_SERVER_SIGN_MAGIC[] =
"session key to server-to-client signing key magic constant";
static const char NTLM_CLIENT_SEAL_MAGIC[] =
"session key to client-to-server sealing key magic constant";
static const char NTLM_SERVER_SEAL_MAGIC[] =
"session key to server-to-client sealing key magic constant";
static const BYTE NTLM_NULL_BUFFER[16] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@ -111,7 +115,7 @@ void ntlm_print_version_info(NTLM_VERSION_INFO* versionInfo)
WLog_INFO(TAG, "\tProductMinorVersion: %"PRIu8"", versionInfo->ProductMinorVersion);
WLog_INFO(TAG, "\tProductBuild: %"PRIu16"", versionInfo->ProductBuild);
WLog_INFO(TAG, "\tReserved: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"", versionInfo->Reserved[0],
versionInfo->Reserved[1], versionInfo->Reserved[2]);
versionInfo->Reserved[1], versionInfo->Reserved[2]);
WLog_INFO(TAG, "\tNTLMRevisionCurrent: 0x%02"PRIX8"", versionInfo->NTLMRevisionCurrent);
}
@ -195,14 +199,14 @@ int ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
WINPR_SAM* sam;
WINPR_SAM_ENTRY* entry;
SSPI_CREDENTIALS* credentials = context->credentials;
sam = SamOpen(context->SamFile, TRUE);
if (!sam)
return -1;
entry = SamLookupUserW(sam, (LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2);
entry = SamLookupUserW(sam, (LPWSTR) credentials->identity.User,
credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2);
if (entry)
{
@ -211,15 +215,16 @@ int ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
winpr_HexDump(TAG, WLOG_DEBUG, entry->NtHash, 16);
#endif
NTOWFv2FromHashW(entry->NtHash,
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
SamFreeEntry(sam, entry);
SamClose(sam);
return 1;
}
entry = SamLookupUserW(sam, (LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2, NULL, 0);
entry = SamLookupUserW(sam, (LPWSTR) credentials->identity.User,
credentials->identity.UserLength * 2, NULL, 0);
if (entry)
{
@ -228,9 +233,9 @@ int ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
winpr_HexDump(TAG, WLOG_DEBUG, entry->NtHash, 16);
#endif
NTOWFv2FromHashW(entry->NtHash,
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
SamFreeEntry(sam, entry);
SamClose(sam);
return 1;
@ -255,7 +260,7 @@ int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash)
/* Password contains a password hash of length (PasswordLength / SSPI_CREDENTIALS_HASH_LENGTH_FACTOR) */
PasswordHashLength = credentials->identity.PasswordLength / SSPI_CREDENTIALS_HASH_LENGTH_FACTOR;
status = ConvertFromUnicode(CP_UTF8, 0, (LPCWSTR) credentials->identity.Password,
PasswordHashLength, &PasswordHash, 0, NULL, NULL);
PasswordHashLength, &PasswordHash, 0, NULL, NULL);
if (status <= 0)
return -1;
@ -283,9 +288,9 @@ int ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
if (memcmp(context->NtlmHash, NTLM_NULL_BUFFER, 16) != 0)
{
NTOWFv2FromHashW(context->NtlmHash,
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
}
else if (credentials->identity.PasswordLength > 256)
{
@ -294,15 +299,15 @@ int ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
return -1;
NTOWFv2FromHashW(context->NtlmHash,
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2,
(BYTE*) hash);
}
else if (credentials->identity.Password)
{
NTOWFv2W((LPWSTR) credentials->identity.Password, credentials->identity.PasswordLength * 2,
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2, (BYTE*) hash);
(LPWSTR) credentials->identity.User, credentials->identity.UserLength * 2,
(LPWSTR) credentials->identity.Domain, credentials->identity.DomainLength * 2, (BYTE*) hash);
}
else if (context->HashCallback)
{
@ -319,9 +324,8 @@ int ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
}
ret = context->HashCallback(context->HashCallbackArg, &credentials->identity, &proofValue,
context->EncryptedRandomSessionKey, context->MessageIntegrityCheck, &micValue,
hash);
context->EncryptedRandomSessionKey, context->MessageIntegrityCheck, &micValue,
hash);
sspi_SecBufferFree(&proofValue);
sspi_SecBufferFree(&micValue);
return ret ? 1 : -1;
@ -363,8 +367,8 @@ int ntlm_compute_lm_v2_response(NTLM_CONTEXT* context)
response = (BYTE*) context->LmChallengeResponse.pvBuffer;
/* Compute the HMAC-MD5 hash of the resulting value using the NTLMv2 hash as the key */
winpr_HMAC(WINPR_MD_MD5, (void*) context->NtlmV2Hash, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) value, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) response, WINPR_MD5_DIGEST_LENGTH);
(BYTE*) value, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) response, WINPR_MD5_DIGEST_LENGTH);
/* Concatenate the resulting HMAC-MD5 hash and the client challenge, giving us the LMv2 response (24 bytes) */
CopyMemory(&response[16], context->ClientChallenge, 8);
return 1;
@ -384,8 +388,6 @@ int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
SecBuffer ntlm_v2_temp;
SecBuffer ntlm_v2_temp_chal;
PSecBuffer TargetInfo;
SSPI_CREDENTIALS* credentials;
credentials = context->credentials;
TargetInfo = &context->ChallengeTargetInfo;
if (!sspi_SecBufferAlloc(&ntlm_v2_temp, TargetInfo->cbBuffer + 28))
@ -400,11 +402,14 @@ int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
#ifdef WITH_DEBUG_NTLM
WLog_DBG(TAG, "Password (length = %"PRIu32")", credentials->identity.PasswordLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.Password, credentials->identity.PasswordLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.Password,
credentials->identity.PasswordLength * 2);
WLog_DBG(TAG, "Username (length = %"PRIu32")", credentials->identity.UserLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.User, credentials->identity.UserLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.User,
credentials->identity.UserLength * 2);
WLog_DBG(TAG, "Domain (length = %"PRIu32")", credentials->identity.DomainLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.Domain, credentials->identity.DomainLength * 2);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) credentials->identity.Domain,
credentials->identity.DomainLength * 2);
WLog_DBG(TAG, "Workstation (length = %"PRIu16")", context->Workstation.Length);
winpr_HexDump(TAG, WLOG_DEBUG, (BYTE*) context->Workstation.Buffer, context->Workstation.Length);
WLog_DBG(TAG, "NTOWFv2, NTLMv2 Hash");
@ -433,8 +438,8 @@ int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
CopyMemory(blob, context->ServerChallenge, 8);
CopyMemory(&blob[8], ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
winpr_HMAC(WINPR_MD_MD5, (BYTE*) context->NtlmV2Hash, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) ntlm_v2_temp_chal.pvBuffer, ntlm_v2_temp_chal.cbBuffer,
(BYTE*) nt_proof_str, WINPR_MD5_DIGEST_LENGTH);
(BYTE*) ntlm_v2_temp_chal.pvBuffer, ntlm_v2_temp_chal.cbBuffer,
(BYTE*) nt_proof_str, WINPR_MD5_DIGEST_LENGTH);
/* NtChallengeResponse, Concatenate NTProofStr with temp */
@ -446,8 +451,8 @@ int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
CopyMemory(&blob[16], ntlm_v2_temp.pvBuffer, ntlm_v2_temp.cbBuffer);
/* Compute SessionBaseKey, the HMAC-MD5 hash of NTProofStr using the NTLMv2 hash as the key */
winpr_HMAC(WINPR_MD_MD5, (BYTE*) context->NtlmV2Hash, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) nt_proof_str, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) context->SessionBaseKey, WINPR_MD5_DIGEST_LENGTH);
(BYTE*) nt_proof_str, WINPR_MD5_DIGEST_LENGTH,
(BYTE*) context->SessionBaseKey, WINPR_MD5_DIGEST_LENGTH);
sspi_SecBufferFree(&ntlm_v2_temp);
sspi_SecBufferFree(&ntlm_v2_temp_chal);
return 1;
@ -464,6 +469,7 @@ int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context)
void ntlm_rc4k(BYTE* key, int length, BYTE* plaintext, BYTE* ciphertext)
{
WINPR_RC4_CTX* rc4 = winpr_RC4_New(key, 16);
if (rc4)
{
winpr_RC4_Update(rc4, length, plaintext, ciphertext);
@ -534,7 +540,8 @@ void ntlm_generate_exported_session_key(NTLM_CONTEXT* context)
void ntlm_encrypt_random_session_key(NTLM_CONTEXT* context)
{
/* In NTLMv2, EncryptedRandomSessionKey is the ExportedSessionKey RC4-encrypted with the KeyExchangeKey */
ntlm_rc4k(context->KeyExchangeKey, 16, context->RandomSessionKey, context->EncryptedRandomSessionKey);
ntlm_rc4k(context->KeyExchangeKey, 16, context->RandomSessionKey,
context->EncryptedRandomSessionKey);
}
/**
@ -553,7 +560,8 @@ void ntlm_decrypt_random_session_key(NTLM_CONTEXT* context)
* Set RandomSessionKey to KeyExchangeKey
*/
if (context->NegotiateKeyExchange)
ntlm_rc4k(context->KeyExchangeKey, 16, context->EncryptedRandomSessionKey, context->RandomSessionKey);
ntlm_rc4k(context->KeyExchangeKey, 16, context->EncryptedRandomSessionKey,
context->RandomSessionKey);
else
CopyMemory(context->RandomSessionKey, context->KeyExchangeKey, 16);
}
@ -570,7 +578,6 @@ int ntlm_generate_signing_key(BYTE* exported_session_key, PSecBuffer sign_magic,
{
int length;
BYTE* value;
length = WINPR_MD5_DIGEST_LENGTH + sign_magic->cbBuffer;
value = (BYTE*) malloc(length);
@ -586,6 +593,7 @@ int ntlm_generate_signing_key(BYTE* exported_session_key, PSecBuffer sign_magic,
free(value);
return -1;
}
free(value);
return 1;
}
@ -639,7 +647,8 @@ int ntlm_generate_sealing_key(BYTE* exported_session_key, PSecBuffer seal_magic,
CopyMemory(p, exported_session_key, WINPR_MD5_DIGEST_LENGTH);
CopyMemory(&p[WINPR_MD5_DIGEST_LENGTH], seal_magic->pvBuffer, seal_magic->cbBuffer);
if (!winpr_Digest(WINPR_MD_MD5, buffer.pvBuffer, buffer.cbBuffer, sealing_key, WINPR_MD5_DIGEST_LENGTH))
if (!winpr_Digest(WINPR_MD_MD5, buffer.pvBuffer, buffer.cbBuffer, sealing_key,
WINPR_MD5_DIGEST_LENGTH))
{
sspi_SecBufferFree(&buffer);
return -1;
@ -710,7 +719,6 @@ void ntlm_compute_message_integrity_check(NTLM_CONTEXT* context)
* Compute the HMAC-MD5 hash of ConcatenationOf(NEGOTIATE_MESSAGE,
* CHALLENGE_MESSAGE, AUTHENTICATE_MESSAGE) using the ExportedSessionKey
*/
WINPR_HMAC_CTX* hmac = winpr_HMAC_New();
if (!hmac)
@ -718,10 +726,14 @@ void ntlm_compute_message_integrity_check(NTLM_CONTEXT* context)
if (winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->ExportedSessionKey, WINPR_MD5_DIGEST_LENGTH))
{
winpr_HMAC_Update(hmac, (BYTE*) context->NegotiateMessage.pvBuffer, context->NegotiateMessage.cbBuffer);
winpr_HMAC_Update(hmac, (BYTE*) context->ChallengeMessage.pvBuffer, context->ChallengeMessage.cbBuffer);
winpr_HMAC_Update(hmac, (BYTE*) context->AuthenticateMessage.pvBuffer, context->AuthenticateMessage.cbBuffer);
winpr_HMAC_Update(hmac, (BYTE*) context->NegotiateMessage.pvBuffer,
context->NegotiateMessage.cbBuffer);
winpr_HMAC_Update(hmac, (BYTE*) context->ChallengeMessage.pvBuffer,
context->ChallengeMessage.cbBuffer);
winpr_HMAC_Update(hmac, (BYTE*) context->AuthenticateMessage.pvBuffer,
context->AuthenticateMessage.cbBuffer);
winpr_HMAC_Final(hmac, context->MessageIntegrityCheck, WINPR_MD5_DIGEST_LENGTH);
}
winpr_HMAC_Free(hmac);
}

View File

@ -3,7 +3,7 @@
* Schannel Security Package
*
* Copyright 2012-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -33,8 +33,8 @@ char* SCHANNEL_PACKAGE_NAME = "Schannel";
SCHANNEL_CONTEXT* schannel_ContextNew()
{
SCHANNEL_CONTEXT* context;
context = (SCHANNEL_CONTEXT*) calloc(1, sizeof(SCHANNEL_CONTEXT));
if (!context)
return NULL;
@ -55,16 +55,13 @@ void schannel_ContextFree(SCHANNEL_CONTEXT* context)
return;
schannel_openssl_free(context->openssl);
free(context);
}
SCHANNEL_CREDENTIALS* schannel_CredentialsNew()
{
SCHANNEL_CREDENTIALS* credentials;
credentials = (SCHANNEL_CREDENTIALS*) calloc(1, sizeof(SCHANNEL_CREDENTIALS));
return credentials;
}
@ -82,57 +79,52 @@ static ALG_ID schannel_SupportedAlgs[] =
CALG_DSS_SIGN, CALG_ECDSA
};
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesW(PCredHandle phCredential,
ULONG ulAttribute, void* pBuffer)
{
if (ulAttribute == SECPKG_ATTR_SUPPORTED_ALGS)
{
PSecPkgCred_SupportedAlgs SupportedAlgs = (PSecPkgCred_SupportedAlgs) pBuffer;
SupportedAlgs->cSupportedAlgs = sizeof(schannel_SupportedAlgs) / sizeof(ALG_ID);
SupportedAlgs->palgSupportedAlgs = (ALG_ID*) schannel_SupportedAlgs;
return SEC_E_OK;
}
else if (ulAttribute == SECPKG_ATTR_CIPHER_STRENGTHS)
{
PSecPkgCred_CipherStrengths CipherStrengths = (PSecPkgCred_CipherStrengths) pBuffer;
CipherStrengths->dwMinimumCipherStrength = 40;
CipherStrengths->dwMaximumCipherStrength = 256;
return SEC_E_OK;
}
else if (ulAttribute == SECPKG_ATTR_SUPPORTED_PROTOCOLS)
{
PSecPkgCred_SupportedProtocols SupportedProtocols = (PSecPkgCred_SupportedProtocols) pBuffer;
/* Observed SupportedProtocols: 0x208A0 */
SupportedProtocols->grbitProtocol = (SP_PROT_CLIENTS | SP_PROT_SERVERS);
return SEC_E_OK;
}
return SEC_E_UNSUPPORTED_FUNCTION;
}
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY schannel_QueryCredentialsAttributesA(PCredHandle phCredential,
ULONG ulAttribute, void* pBuffer)
{
return schannel_QueryCredentialsAttributesW(phCredential, ulAttribute, pBuffer);
}
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal,
SEC_WCHAR* pszPackage,
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
SCHANNEL_CREDENTIALS* credentials;
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
{
SCHANNEL_CRED* cred;
credentials = schannel_CredentialsNew();
credentials->fCredentialUse = fCredentialUse;
cred = (SCHANNEL_CRED*) pAuthData;
if (cred)
@ -142,41 +134,35 @@ SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(SEC_WCHAR* pszPrinc
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
return SEC_E_OK;
}
else if (fCredentialUse == SECPKG_CRED_INBOUND)
{
credentials = schannel_CredentialsNew();
credentials->fCredentialUse = fCredentialUse;
sspi_SecureHandleSetLowerPointer(phCredential, (void*) credentials);
sspi_SecureHandleSetUpperPointer(phCredential, (void*) SCHANNEL_PACKAGE_NAME);
return SEC_E_OK;
}
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal,
SEC_CHAR* pszPackage,
ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status;
SEC_WCHAR* pszPrincipalW = NULL;
SEC_WCHAR* pszPackageW = NULL;
ConvertToUnicode(CP_UTF8, 0, pszPrincipal, -1, &pszPrincipalW, 0);
ConvertToUnicode(CP_UTF8, 0, pszPackage, -1, &pszPackageW, 0);
status = schannel_AcquireCredentialsHandleW(pszPrincipalW, pszPackageW, fCredentialUse, pvLogonID,
pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
free(pszPrincipalW);
free(pszPackageW);
return SEC_E_OK;
return status;
}
SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredential)
@ -192,19 +178,18 @@ SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredentia
return SEC_E_INVALID_HANDLE;
schannel_CredentialsFree(credentials);
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextW(PCredHandle phCredential,
PCtxtHandle phContext,
SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status;
SCHANNEL_CONTEXT* context;
SCHANNEL_CREDENTIALS* credentials;
context = sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
@ -215,25 +200,22 @@ SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextW(PCredHandle phCred
return SEC_E_INSUFFICIENT_MEMORY;
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
context->server = FALSE;
CopyMemory(&context->cred, &credentials->cred, sizeof(SCHANNEL_CRED));
sspi_SecureHandleSetLowerPointer(phNewContext, context);
sspi_SecureHandleSetUpperPointer(phNewContext, (void*) SCHANNEL_PACKAGE_NAME);
schannel_openssl_client_init(context->openssl);
}
status = schannel_openssl_client_process_tokens(context->openssl, pInput, pOutput);
return status;
}
SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(PCredHandle phCredential,
PCtxtHandle phContext,
SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status;
SEC_WCHAR* pszTargetNameW = NULL;
@ -244,22 +226,18 @@ SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(PCredHandle phCred
}
status = schannel_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
free(pszTargetNameW);
return status;
}
SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredential,
PCtxtHandle phContext,
PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
{
SECURITY_STATUS status;
SCHANNEL_CONTEXT* context;
SCHANNEL_CREDENTIALS* credentials;
status = SEC_E_OK;
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
@ -269,36 +247,30 @@ SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(PCredHandle phCredentia
if (!context)
return SEC_E_INSUFFICIENT_MEMORY;
credentials = (SCHANNEL_CREDENTIALS*) sspi_SecureHandleGetLowerPointer(phCredential);
context->server = TRUE;
sspi_SecureHandleSetLowerPointer(phNewContext, context);
sspi_SecureHandleSetUpperPointer(phNewContext, (void*) SCHANNEL_PACKAGE_NAME);
schannel_openssl_server_init(context->openssl);
}
status = schannel_openssl_server_process_tokens(context->openssl, pInput, pOutput);
return status;
}
SECURITY_STATUS SEC_ENTRY schannel_DeleteSecurityContext(PCtxtHandle phContext)
{
SCHANNEL_CONTEXT* context;
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
return SEC_E_INVALID_HANDLE;
schannel_ContextFree(context);
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute, void* pBuffer)
SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext, ULONG ulAttribute,
void* pBuffer)
{
if (!phContext)
return SEC_E_INVALID_HANDLE;
@ -309,67 +281,63 @@ SECURITY_STATUS SEC_ENTRY schannel_QueryContextAttributes(PCtxtHandle phContext,
if (ulAttribute == SECPKG_ATTR_SIZES)
{
SecPkgContext_Sizes* Sizes = (SecPkgContext_Sizes*) pBuffer;
Sizes->cbMaxToken = 0x6000;
Sizes->cbMaxSignature = 16;
Sizes->cbBlockSize = 0;
Sizes->cbSecurityTrailer = 16;
return SEC_E_OK;
}
else if (ulAttribute == SECPKG_ATTR_STREAM_SIZES)
{
SecPkgContext_StreamSizes* StreamSizes = (SecPkgContext_StreamSizes*) pBuffer;
StreamSizes->cbHeader = 5;
StreamSizes->cbTrailer = 36;
StreamSizes->cbMaximumMessage = 0x4000;
StreamSizes->cBuffers = 4;
StreamSizes->cbBlockSize = 16;
return SEC_E_OK;
}
return SEC_E_UNSUPPORTED_FUNCTION;
}
SECURITY_STATUS SEC_ENTRY schannel_MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
SECURITY_STATUS SEC_ENTRY schannel_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY schannel_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
SECURITY_STATUS SEC_ENTRY schannel_VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage,
ULONG MessageSeqNo, ULONG* pfQOP)
{
return SEC_E_OK;
}
SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
SECURITY_STATUS status;
SCHANNEL_CONTEXT* context;
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
return SEC_E_INVALID_HANDLE;
status = schannel_openssl_encrypt_message(context->openssl, pMessage);
return status;
}
SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, ULONG* pfQOP)
SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage,
ULONG MessageSeqNo, ULONG* pfQOP)
{
SECURITY_STATUS status;
SCHANNEL_CONTEXT* context;
context = (SCHANNEL_CONTEXT*) sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
return SEC_E_INVALID_HANDLE;
status = schannel_openssl_decrypt_message(context->openssl, pMessage);
return status;
}
@ -447,13 +415,13 @@ const SecPkgInfoA SCHANNEL_SecPkgInfoA =
"Schannel Security Package" /* Comment */
};
WCHAR SCHANNEL_SecPkgInfoW_Name[] = { 'S','c','h','a','n','n','e','l','\0' };
WCHAR SCHANNEL_SecPkgInfoW_Name[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', '\0' };
WCHAR SCHANNEL_SecPkgInfoW_Comment[] =
{
'S','c','h','a','n','n','e','l',' ',
'S','e','c','u','r','i','t','y',' ',
'P','a','c','k','a','g','e','\0'
'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l', ' ',
'S', 'e', 'c', 'u', 'r', 'i', 't', 'y', ' ',
'P', 'a', 'c', 'k', 'a', 'g', 'e', '\0'
};
const SecPkgInfoW SCHANNEL_SecPkgInfoW =

View File

@ -114,11 +114,13 @@ BOOL InitializeSspiModule_Native(void)
static BOOL CALLBACK InitializeSspiModuleInt(PINIT_ONCE once, PVOID param, PVOID* context)
{
BOOL status = FALSE;
#if defined(WITH_NATIVE_SSPI)
DWORD flags = 0;
if (param)
flags = *(DWORD*)param;
#endif
sspi_GlobalInit();
g_Log = WLog_Get("com.winpr.sspi");
#if defined(WITH_NATIVE_SSPI)

View File

@ -65,20 +65,20 @@ extern const SecurityFunctionTableW SCHANNEL_SecurityFunctionTableW;
static const SecPkgInfoA* SecPkgInfoA_LIST[] =
{
&NTLM_SecPkgInfoA,
&KERBEROS_SecPkgInfoA,
&NEGOTIATE_SecPkgInfoA,
&CREDSSP_SecPkgInfoA,
&SCHANNEL_SecPkgInfoA
&NTLM_SecPkgInfoA,
&KERBEROS_SecPkgInfoA,
&NEGOTIATE_SecPkgInfoA,
&CREDSSP_SecPkgInfoA,
&SCHANNEL_SecPkgInfoA
};
static const SecPkgInfoW* SecPkgInfoW_LIST[] =
{
&NTLM_SecPkgInfoW,
&KERBEROS_SecPkgInfoW,
&NEGOTIATE_SecPkgInfoW,
&CREDSSP_SecPkgInfoW,
&SCHANNEL_SecPkgInfoW
&NTLM_SecPkgInfoW,
&KERBEROS_SecPkgInfoW,
&NEGOTIATE_SecPkgInfoW,
&CREDSSP_SecPkgInfoW,
&SCHANNEL_SecPkgInfoW
};
static SecurityFunctionTableA winpr_SecurityFunctionTableA;
@ -100,11 +100,11 @@ typedef struct _SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME;
static const SecurityFunctionTableA_NAME SecurityFunctionTableA_NAME_LIST[] =
{
{ "NTLM", &NTLM_SecurityFunctionTableA },
{ "Kerberos", &KERBEROS_SecurityFunctionTableA },
{ "Negotiate", &NEGOTIATE_SecurityFunctionTableA },
{ "CREDSSP", &CREDSSP_SecurityFunctionTableA },
{ "Schannel", &SCHANNEL_SecurityFunctionTableA }
{ "NTLM", &NTLM_SecurityFunctionTableA },
{ "Kerberos", &KERBEROS_SecurityFunctionTableA },
{ "Negotiate", &NEGOTIATE_SecurityFunctionTableA },
{ "CREDSSP", &CREDSSP_SecurityFunctionTableA },
{ "Schannel", &SCHANNEL_SecurityFunctionTableA }
};
static const WCHAR NTLM_NAME_W[] = { 'N', 'T', 'L', 'M', '\0' };
@ -115,11 +115,11 @@ static const WCHAR SCHANNEL_NAME_W[] = { 'S', 'c', 'h', 'a', 'n', 'n', 'e', 'l',
static const SecurityFunctionTableW_NAME SecurityFunctionTableW_NAME_LIST[] =
{
{ NTLM_NAME_W, &NTLM_SecurityFunctionTableW },
{ KERBEROS_NAME_W, &KERBEROS_SecurityFunctionTableW },
{ NEGOTIATE_NAME_W, &NEGOTIATE_SecurityFunctionTableW },
{ CREDSSP_NAME_W, &CREDSSP_SecurityFunctionTableW },
{ SCHANNEL_NAME_W, &SCHANNEL_SecurityFunctionTableW }
{ NTLM_NAME_W, &NTLM_SecurityFunctionTableW },
{ KERBEROS_NAME_W, &KERBEROS_SecurityFunctionTableW },
{ NEGOTIATE_NAME_W, &NEGOTIATE_SecurityFunctionTableW },
{ CREDSSP_NAME_W, &CREDSSP_SecurityFunctionTableW },
{ SCHANNEL_NAME_W, &SCHANNEL_SecurityFunctionTableW }
};
#define SecHandle_LOWER_MAX 0xFFFFFFFF
@ -353,18 +353,17 @@ int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, co
{
int unicodePasswordLenW;
LPWSTR unicodePassword = NULL;
unicodePasswordLenW = ConvertToUnicode(CP_UTF8, 0, password, -1, &unicodePassword, 0);
if (unicodePasswordLenW <= 0)
return -1;
return sspi_SetAuthIdentityWithUnicodePassword(identity, user, domain, unicodePassword,
(ULONG)(unicodePasswordLenW - 1));
(ULONG)(unicodePasswordLenW - 1));
}
int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, const char *user,
const char *domain, LPWSTR password, ULONG passwordLength)
int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, const char* user,
const char* domain, LPWSTR password, ULONG passwordLength)
{
int status;
identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
@ -398,12 +397,12 @@ int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, c
free(identity->Password);
identity->Password = (UINT16*) calloc(1, (passwordLength + 1) * sizeof(WCHAR));
if (!identity->Password)
return -1;
CopyMemory(identity->Password, password, passwordLength * sizeof(WCHAR));
identity->PasswordLength = passwordLength;
return 1;
}
@ -500,7 +499,6 @@ void sspi_GlobalInit(void)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
DWORD flags = 0;
InitOnceExecuteOnce(&once, sspi_init, &flags, NULL);
}
@ -526,11 +524,6 @@ static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_C
return NULL;
}
static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameW(const SEC_WCHAR* Name)
{
return NULL;
}
static SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name)
{
int index;
@ -583,13 +576,13 @@ static void sspi_ContextBufferFree(void* contextBuffer)
switch (allocatorIndex)
{
case EnumerateSecurityPackagesIndex:
FreeContextBuffer_EnumerateSecurityPackages(contextBuffer);
break;
case EnumerateSecurityPackagesIndex:
FreeContextBuffer_EnumerateSecurityPackages(contextBuffer);
break;
case QuerySecurityPackageInfoIndex:
FreeContextBuffer_QuerySecurityPackageInfo(contextBuffer);
break;
case QuerySecurityPackageInfoIndex:
FreeContextBuffer_QuerySecurityPackageInfo(contextBuffer);
break;
}
}
}
@ -1552,64 +1545,64 @@ static SECURITY_STATUS SEC_ENTRY winpr_VerifySignature(PCtxtHandle phContext,
static SecurityFunctionTableA winpr_SecurityFunctionTableA =
{
1, /* dwVersion */
winpr_EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
winpr_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
winpr_InitializeSecurityContextA, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
winpr_ApplyControlToken, /* ApplyControlToken */
winpr_QueryContextAttributesA, /* QueryContextAttributes */
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
winpr_RevertSecurityContext, /* RevertSecurityContext */
winpr_MakeSignature, /* MakeSignature */
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextA, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
winpr_SetContextAttributesA, /* SetContextAttributes */
1, /* dwVersion */
winpr_EnumerateSecurityPackagesA, /* EnumerateSecurityPackages */
winpr_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
winpr_InitializeSecurityContextA, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
winpr_ApplyControlToken, /* ApplyControlToken */
winpr_QueryContextAttributesA, /* QueryContextAttributes */
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
winpr_RevertSecurityContext, /* RevertSecurityContext */
winpr_MakeSignature, /* MakeSignature */
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextA, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
winpr_SetContextAttributesA, /* SetContextAttributes */
};
static SecurityFunctionTableW winpr_SecurityFunctionTableW =
{
1, /* dwVersion */
winpr_EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
winpr_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
winpr_InitializeSecurityContextW, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
winpr_ApplyControlToken, /* ApplyControlToken */
winpr_QueryContextAttributesW, /* QueryContextAttributes */
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
winpr_RevertSecurityContext, /* RevertSecurityContext */
winpr_MakeSignature, /* MakeSignature */
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextW, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
winpr_SetContextAttributesW, /* SetContextAttributes */
1, /* dwVersion */
winpr_EnumerateSecurityPackagesW, /* EnumerateSecurityPackages */
winpr_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
NULL, /* Reserved2 */
winpr_InitializeSecurityContextW, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
winpr_DeleteSecurityContext, /* DeleteSecurityContext */
winpr_ApplyControlToken, /* ApplyControlToken */
winpr_QueryContextAttributesW, /* QueryContextAttributes */
winpr_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
winpr_RevertSecurityContext, /* RevertSecurityContext */
winpr_MakeSignature, /* MakeSignature */
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
NULL, /* Reserved3 */
NULL, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextW, /* ImportSecurityContext */
NULL, /* AddCredentials */
NULL, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
winpr_SetContextAttributesW, /* SetContextAttributes */
};

View File

@ -12,7 +12,7 @@ int TestAcquireCredentialsHandle(int argc, char* argv[])
{
int rc = -1;
SECURITY_STATUS status;
CredHandle credentials;
CredHandle credentials = { 0 };
TimeStamp expiration;
SEC_WINNT_AUTH_IDENTITY identity;
SecurityFunctionTable* table;

View File

@ -17,7 +17,7 @@ int TestInitializeSecurityContext(int argc, char* argv[])
CtxtHandle context;
ULONG pfContextAttr;
SECURITY_STATUS status;
CredHandle credentials;
CredHandle credentials = { 0 };
TimeStamp expiration;
PSecPkgInfo pPackageInfo;
SEC_WINNT_AUTH_IDENTITY identity = { 0 };

View File

@ -366,7 +366,6 @@ int IniFile_Load(wIniFile* ini)
char* value;
char* separator;
char* beg, *end;
wIniFileKey* key = NULL;
wIniFileSection* section = NULL;
while (IniFile_Load_HasNextLine(ini))
@ -417,14 +416,7 @@ int IniFile_Load(wIniFile* ini)
value = beg;
if (!IniFile_AddKey(ini, section, name, value))
{
return -1;
}
key = NULL;
if (section && section->keys)
key = section->keys[section->nKeys - 1];
}
}