Merge pull request #1448 from akallabeth/coverity_fixes

Multiple resource leak and NULL pointer dereferencing fixes
This commit is contained in:
Bernhard Miklautz 2013-09-10 00:56:30 -07:00
commit 8baa04e7e5
84 changed files with 859 additions and 209 deletions

View File

@ -152,7 +152,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
endif()
if(CMAKE_COMPILER_IS_CLANG)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Weverything -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-macros -Wno-padded")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-c11-extensions -Wno-gnu")
if(WITH_SSE2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
endif()

View File

@ -540,3 +540,4 @@ int freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEnt
return 0;
}

View File

@ -182,10 +182,14 @@ FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPSTR pszName, LPSTR pszSub
NativePathCchAppendA(pszSearchPath, cchSearchPath + 1, pszAddinPath);
NativePathCchAppendA(pszSearchPath, cchSearchPath + 1, pszPattern);
free(pszPattern);
cchSearchPath = strlen(pszSearchPath);
hFind = FindFirstFileA(pszSearchPath, &FindData);
free(pszSearchPath);
nAddins = 0;
ppAddins = (FREERDP_ADDIN**) malloc(sizeof(FREERDP_ADDIN*) * 128);
ppAddins[nAddins] = NULL;

View File

@ -62,21 +62,25 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
for (i = 0; i < cb_event->num_formats; i++)
{
const char* name;
int name_length;
int name_length, short_name_length = 32, x;
switch (cb_event->formats[i])
{
case CB_FORMAT_HTML:
name = CFSTR_HTML; name_length = sizeof(CFSTR_HTML);
name = CFSTR_HTML;
name_length = sizeof(CFSTR_HTML);
break;
case CB_FORMAT_PNG:
name = CFSTR_PNG; name_length = sizeof(CFSTR_PNG);
name = CFSTR_PNG;
name_length = sizeof(CFSTR_PNG);
break;
case CB_FORMAT_JPEG:
name = CFSTR_JPEG; name_length = sizeof(CFSTR_JPEG);
name = CFSTR_JPEG;
name_length = sizeof(CFSTR_JPEG);
break;
case CB_FORMAT_GIF:
name = CFSTR_GIF; name_length = sizeof(CFSTR_GIF);
name = CFSTR_GIF;
name_length = sizeof(CFSTR_GIF);
break;
default:
name = "\0\0";
@ -85,12 +89,23 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
}
if (!cliprdr->use_long_format_names)
name_length = 32;
Stream_EnsureRemainingCapacity(body, 4 + name_length);
{
x = (name_length > short_name_length) ?
name_length : short_name_length;
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, name_length);
Stream_EnsureRemainingCapacity(body, 4 + short_name_length);
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, x);
while (x++ < short_name_length)
Stream_Write(body, "\0", 1);
}
else
{
Stream_EnsureRemainingCapacity(body, 4 + name_length);
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, name_length);
}
}
Stream_SealLength(body);

View File

@ -117,7 +117,7 @@ static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* disk, UINT32 id)
static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
char* path = NULL;
int status;
UINT32 FileId;
DRIVE_FILE* file;

View File

@ -137,7 +137,7 @@ static void parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
buffer = (BYTE*) malloc(Length);
status = read(parallel->file, irp->output->pointer, Length);
status = read(parallel->file, buffer, Length);
if (status < 0)
{

View File

@ -146,8 +146,10 @@ void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
rdpsnd->NumberOfClientFormats = 0;
rdpsnd->ClientFormats = NULL;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
if (!rdpsnd->NumberOfServerFormats)
return;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++)
{
serverFormat = &rdpsnd->ServerFormats[index];
@ -417,7 +419,10 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
wave->wAudioLength = rdpsnd_compute_audio_time_length(format, size);
if (!rdpsnd->device)
{
free(wave);
return;
}
if (rdpsnd->device->WaveDecode)
{
@ -439,6 +444,8 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
wave->wLocalTimeB = wave->wLocalTimeA + wave->wAudioLength + TIME_DELAY_MS;
rdpsnd->device->WaveConfirm(rdpsnd->device, wave);
}
else
free(wave);
}
static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd)

View File

@ -23,13 +23,11 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <strings.h>
#include <pthread.h>
#include <semaphore.h>
#define BOOL PCSC_BOOL
#include <PCSC/pcsclite.h>
@ -153,6 +151,7 @@ static void smartcard_output_buffer_limit(IRP* irp, char* buffer, unsigned int l
}
else
{
assert(NULL != buffer);
if (header < length)
length = header;
@ -485,6 +484,11 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
(unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
(unsigned) cur->dwEventState);
if (!cur->szReader)
{
DEBUG_WARN("cur->szReader=%p", cur->szReader);
continue;
}
if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
cur->dwCurrentState |= SCARD_STATE_IGNORE;
}
@ -966,15 +970,19 @@ static UINT32 handle_Transmit(IRP* irp)
Stream_Write_UINT32(irp->output, 0); /* pioRecvPci 0x00; */
smartcard_output_buffer_start(irp, cbRecvLength); /* start of recvBuf output */
smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
if (recvBuf)
{
smartcard_output_buffer_start(irp, cbRecvLength); /* start of recvBuf output */
smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
}
}
smartcard_output_alignment(irp, 8);
free(sendBuf);
free(recvBuf);
if (sendBuf)
free(sendBuf);
if (recvBuf)
free(recvBuf);
return status;
}
@ -1032,7 +1040,10 @@ static UINT32 handle_Control(IRP* irp)
sendBuffer = malloc(outBufferSize);
if (!sendBuffer)
{
free(recvBuffer);
return smartcard_output_return(irp, SCARD_E_NO_MEMORY);
}
status = SCardControl(hCard, (DWORD) controlCode, recvBuffer, (DWORD) recvLength,
sendBuffer, (DWORD) outBufferSize, &nBytesReturned);
@ -1231,7 +1242,10 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE));
if (!readerStates)
{
free(pAtrMasks);
return smartcard_output_return(irp, SCARD_E_NO_MEMORY);
}
for (i = 0; i < readerCount; i++)
{
@ -1271,6 +1285,11 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
(unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
(unsigned) cur->dwEventState);
if (!cur->szReader)
{
DEBUG_WARN("cur->szReader=%p", cur->szReader);
continue;
}
if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
cur->dwCurrentState |= SCARD_STATE_IGNORE;
}
@ -1281,6 +1300,8 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
DEBUG_SCARD("Failure: %s (0x%08x)",
pcsc_stringify_error(status), (unsigned) status);
free(readerStates);
free(pAtrMasks);
return smartcard_output_return(irp, status);
}
@ -1310,7 +1331,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
Stream_Write_UINT32(irp->output, 0x00084dd8);
Stream_Write_UINT32(irp->output, readerCount);
for (i = 0, rsCur = readerStates; i < readerCount; i++, rsCur++)
for (i = 0, cur = readerStates; i < readerCount; i++, cur++)
{
Stream_Write_UINT32(irp->output, cur->dwCurrentState);
Stream_Write_UINT32(irp->output, cur->dwEventState);
@ -1325,6 +1346,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
smartcard_output_alignment(irp, 8);
free(readerStates);
free(pAtrMasks);
return status;
}

View File

@ -74,11 +74,11 @@ static BOOL tsmf_alsa_open(ITSMFAudioDevice* audio, const char* device)
if (!device)
{
if (!alsa->device[0])
strcpy(alsa->device, "default");
strncpy(alsa->device, "default", sizeof(alsa->device));
}
else
{
strcpy(alsa->device, device);
strncpy(alsa->device, device, sizeof(alsa->device));
}
return tsmf_alsa_open_device(alsa);

View File

@ -279,6 +279,7 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
default:
LLOGLN(urbdrc_debug, ("urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode));
zfree(OutputBuffer);
return -1;
break;
}
@ -1718,6 +1719,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
break;
default:
fprintf(stderr, "urb_control_feature_request: Error Command %x\n", command);
zfree(out_data);
return -1;
}

View File

@ -485,6 +485,7 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(LIBUSB_DEVICE* libusb_dev)
if (ret < 0)
{
fprintf(stderr, "libusb_get_device_descriptor: ERROR!!\n");
free(descriptor);
return NULL;
}
@ -1543,6 +1544,9 @@ static int func_cancel_xact_request(TRANSFER_REQUEST *request)
{
int status;
if (!request)
return -1;
if ((!request->transfer) || (request->endpoint != request->transfer->endpoint) ||
(request->transfer->endpoint == 0) || (request->submit != 1))
{
@ -1583,6 +1587,8 @@ cancel_retry:
while (request_queue->has_next(request_queue))
{
request = request_queue->get_next(request_queue);
if (!request)
continue;
LLOGLN(libusb_debug, ("%s: CancelId:0x%x RequestId:0x%x endpoint 0x%x!!",
__func__, RequestId, request->RequestId, request->endpoint));

View File

@ -18,6 +18,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -287,6 +288,9 @@ static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, UINT32 M
LLOGLN(10, ("urdbrc_send_virtual_channel_add"));
assert(NULL != channel);
assert(NULL != channel->Write);
InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK);
out_size = 12;
@ -830,7 +834,10 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
transfer_data = (TRANSFER_DATA*) malloc(sizeof(TRANSFER_DATA));
if (transfer_data == NULL)
{
fprintf(stderr, "transfer_data is NULL!!");
return 0;
}
transfer_data->callback = callback;
transfer_data->urbdrc = urbdrc;

View File

@ -206,9 +206,6 @@ int tfreerdp_run(freerdp* instance)
fd_set wfds_set;
rdpChannels* channels;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
channels = instance->context->channels;
freerdp_connect(instance);
@ -218,6 +215,8 @@ int tfreerdp_run(freerdp* instance)
rcount = 0;
wcount = 0;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -11,7 +11,7 @@
LPSTR tmp = NULL;
LPCSTR tr_esc_str(LPCSTR arg)
LPSTR tr_esc_str(LPSTR arg)
{
size_t cs = 0, x, ds;
size_t s;
@ -26,7 +26,8 @@ LPCSTR tr_esc_str(LPCSTR arg)
s--;
/* Prepare a initial buffer with the size of the result string. */
tmp = malloc(s * sizeof(LPCSTR));
if (s)
tmp = (LPSTR)malloc(s * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not allocate string buffer.");
@ -41,7 +42,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
{
case '<':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -54,7 +55,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '>':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -67,7 +68,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '\'':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -82,7 +83,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '"':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -97,7 +98,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '&':
ds += 4;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");

View File

@ -1650,7 +1650,7 @@ void xf_ParamChangeEventHandler(rdpContext* context, ParamChangeEventArgs* e)
}
}
void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
static void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
@ -1668,12 +1668,12 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
xf_transform_window(xfc);
{
ResizeWindowEventArgs e;
ResizeWindowEventArgs ev;
EventArgsInit(&e, "xfreerdp");
e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e);
EventArgsInit(&ev, "xfreerdp");
ev.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
ev.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &ev);
}
xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE);
@ -1683,19 +1683,19 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
* Client Interface
*/
void xfreerdp_client_global_init()
static void xfreerdp_client_global_init()
{
setlocale(LC_ALL, "");
freerdp_handle_signals();
freerdp_channels_global_init();
}
void xfreerdp_client_global_uninit()
static void xfreerdp_client_global_uninit()
{
freerdp_channels_global_uninit();
}
int xfreerdp_client_start(rdpContext* context)
static int xfreerdp_client_start(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
@ -1712,7 +1712,7 @@ int xfreerdp_client_start(rdpContext* context)
return 0;
}
int xfreerdp_client_stop(rdpContext* context)
static int xfreerdp_client_stop(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
@ -1735,7 +1735,7 @@ int xfreerdp_client_stop(rdpContext* context)
return 0;
}
int xfreerdp_client_new(freerdp* instance, rdpContext* context)
static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
{
xfContext* xfc;
rdpSettings* settings;
@ -1791,7 +1791,7 @@ int xfreerdp_client_new(freerdp* instance, rdpContext* context)
return 0;
}
void xfreerdp_client_free(freerdp* instance, rdpContext* context)
static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
{
xfContext* xfc = (xfContext*) context;

View File

@ -998,6 +998,8 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
surface_bits_command->destLeft, surface_bits_command->destTop,
surface_bits_command->width, surface_bits_command->height);
XFree(image);
free(xfc->bmp_codec_nsc);
xfc->bmp_codec_nsc = NULL;
xf_gdi_surface_update_frame(xfc,
surface_bits_command->destLeft, surface_bits_command->destTop,
@ -1026,6 +1028,8 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
surface_bits_command->destLeft, surface_bits_command->destTop,
surface_bits_command->width, surface_bits_command->height);
XFree(image);
free(xfc->bmp_codec_none);
xfc->bmp_codec_none = NULL;
xf_gdi_surface_update_frame(xfc,
surface_bits_command->destLeft, surface_bits_command->destTop,

View File

@ -565,7 +565,7 @@ const char* movetype_names[] =
void xf_process_rail_server_localmovesize_event(xfContext* xfc, rdpChannels* channels, wMessage* event)
{
int x, y;
int x = 0, y = 0;
rdpRail* rail;
int direction = 0;
Window child_window;

View File

@ -832,6 +832,7 @@ void xf_SetWindowIcon(xfContext* xfc, xfWindow* window, rdpIcon* icon)
PropModeReplace, (BYTE*) propdata, propsize);
XFlush(xfc->display);
free(propdata);
}
void xf_SetWindowRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects)

View File

@ -1153,6 +1153,8 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
{
settings->MonitorIds[i] = atoi(p[i]);
}
free(p);
}
}
CommandLineSwitchCase(arg, "monitor-list")

View File

@ -125,6 +125,9 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
}
else if (strcmp(args->argv[0], "rdpdr") == 0)
{
if (args->argc < 2)
return -1;
if ((strcmp(args->argv[1], "disk") == 0) ||
(strcmp(args->argv[1], "drive") == 0))
{
@ -156,11 +159,17 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
}
else if (strcmp(args->argv[0], "rdpsnd") == 0)
{
if (args->argc < 2)
return -1;
freerdp_addin_replace_argument_value(args, args->argv[1], "sys", args->argv[1]);
freerdp_client_add_static_channel(settings, args->argc, args->argv);
}
else if (strcmp(args->argv[0], "rail") == 0)
{
if (args->argc < 2)
return -1;
settings->RemoteApplicationProgram = _strdup(args->argv[1]);
}
else
@ -246,10 +255,9 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
a = p;
}
p = strchr(p, ':');
if (p != NULL)
{
p = strchr(p, ':');
length = p - a;
args->argv[j + 1] = malloc(length + 1);
CopyMemory(args->argv[j + 1], a, length);
@ -279,6 +287,11 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
}
}
for (i=0; i<args->argc; i++)
free(args->argv[i]);
free(args->argv);
free(args);
return (index - old_index);
}

View File

@ -456,7 +456,10 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
fseek(fp, 0, SEEK_SET);
if (file_size < 1)
{
fclose(fp);
return FALSE;
}
buffer = (BYTE*) malloc(file_size + 2);
read_size = fread(buffer, file_size, 1, fp);
@ -466,6 +469,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
if (!ferror(fp))
read_size = file_size;
}
fclose(fp);
if (read_size < 1)
{
@ -669,14 +673,19 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~((size_t) file->Username))
{
char* user;
char* domain;
char* user = NULL;
char* domain = NULL;
freerdp_parse_username(file->Username, &user, &domain);
freerdp_set_param_string(settings, FreeRDP_Username, user);
if (domain != NULL)
freerdp_set_param_string(settings, FreeRDP_Domain, domain);
if (user)
free(user);
if(domain)
free(domain);
}
if (~file->ServerPort)

View File

@ -118,7 +118,10 @@ FREERDP_API CryptoCert crypto_cert_read(BYTE* data, UINT32 length);
FREERDP_API char* crypto_cert_fingerprint(X509* xcert);
FREERDP_API char* crypto_cert_subject(X509* xcert);
FREERDP_API char* crypto_cert_subject_common_name(X509* xcert, int* length);
FREERDP_API char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths);
FREERDP_API char** crypto_cert_subject_alt_name(X509* xcert, int* count,
int** lengths);
FREERDP_API void crypto_cert_subject_alt_name_free(int count, int *lengths,
char** alt_name);
FREERDP_API char* crypto_cert_issuer(X509* xcert);
FREERDP_API void crypto_cert_print_info(X509* xcert);
FREERDP_API void crypto_cert_free(CryptoCert cert);

View File

@ -23,7 +23,12 @@
#include <stdio.h>
#define DEBUG_NULL(fmt, ...) do { } while (0)
#define DEBUG_PRINT(_dbg_str, fmt, ...) fprintf(stderr, _dbg_str fmt "\n" , __FUNCTION__, __LINE__, ## __VA_ARGS__)
#define DEBUG_PRINT(_dbg_str, fmt, ...) do { \
fprintf(stderr, _dbg_str, __FUNCTION__, __LINE__); \
fprintf(stderr, fmt, ## __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while( 0 )
#define DEBUG_CLASS(_dbg_class, fmt, ...) DEBUG_PRINT("DBG_" #_dbg_class " %s (%d): ", fmt, ## __VA_ARGS__)
#define DEBUG_WARN(fmt, ...) DEBUG_PRINT("Warning %s (%d): ", fmt, ## __VA_ARGS__)

View File

@ -22,7 +22,7 @@
#endif
#include <stdio.h>
#include <assert.h>
#include <winpr/crt.h>
#include <freerdp/update.h>
@ -73,7 +73,7 @@ void update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
brush->style = style;
}
void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
static void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
{
int length;
void* data = NULL;
@ -91,6 +91,9 @@ void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
{
void* entry;
assert(brush);
assert(bpp);
if (*bpp == 1)
{
if (index >= brush->maxMonoEntries)
@ -132,6 +135,8 @@ void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp
if (index >= brush->maxMonoEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}
@ -148,6 +153,8 @@ void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp
if (index >= brush->maxEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}

View File

@ -403,7 +403,8 @@ void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGly
if (prevGlyph != NULL)
{
Glyph_Free(glyph_cache->context, prevGlyph);
free(prevGlyph->aj);
if (NULL != prevGlyph->aj)
free(prevGlyph->aj);
free(prevGlyph);
}
@ -498,12 +499,14 @@ void glyph_cache_free(rdpGlyphCache* glyph_cache)
if (glyph != NULL)
{
Glyph_Free(glyph_cache->context, glyph);
free(glyph->aj);
if (glyph->aj)
free(glyph->aj);
free(glyph);
glyph_cache->glyphCache[i].entries[j] = NULL;
}
}
free(glyph_cache->glyphCache[i].entries);
glyph_cache->glyphCache[i].entries = NULL;
}
for (i = 0; i < 255; i++)

View File

@ -27,7 +27,8 @@
#include <freerdp/cache/palette.h>
void update_gdi_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cache_color_table)
static void update_gdi_cache_color_table(rdpContext* context,
CACHE_COLOR_TABLE_ORDER* cache_color_table)
{
UINT32* colorTable;
rdpCache* cache = context->cache;
@ -49,7 +50,6 @@ void* palette_cache_get(rdpPaletteCache* palette_cache, UINT32 index)
}
entry = palette_cache->entries[index].entry;
if (entry == NULL)
{
fprintf(stderr, "invalid color table at index: 0x%04X\n", index);
@ -64,9 +64,14 @@ void palette_cache_put(rdpPaletteCache* palette_cache, UINT32 index, void* entry
if (index >= palette_cache->maxEntries)
{
fprintf(stderr, "invalid color table index: 0x%04X\n", index);
if (entry)
free(entry);
return;
}
if(NULL == palette_cache->entries[index].entry)
free(palette_cache->entries[index].entry);
palette_cache->entries[index].entry = entry;
}
@ -97,6 +102,13 @@ void palette_cache_free(rdpPaletteCache* palette_cache)
{
if (palette_cache != NULL)
{
int i;
for (i=0; i<palette_cache->maxEntries; i++)
{
if (palette_cache->entries[i].entry)
free(palette_cache->entries[i].entry);
}
free(palette_cache->entries);
free(palette_cache);
}

View File

@ -909,7 +909,11 @@ BYTE* freerdp_icon_convert(BYTE* srcData, BYTE* dstData, BYTE* mask, int width,
for (bit = 0; bit < 8; bit++)
if ((bmask & (0x80 >> bit)) == 0)
*(icon + (height - y - 1) * width + x + bit) |= 0xFF000000;
{
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
if (tmp)
*tmp |= 0xFF000000;
}
}
if ((width % 8) != 0)
@ -918,7 +922,11 @@ BYTE* freerdp_icon_convert(BYTE* srcData, BYTE* dstData, BYTE* mask, int width,
for (bit = 0; bit < width % 8; bit++)
if ((bmask & (0x80 >> bit)) == 0)
*(icon + (height - y - 1) * width + x + bit) |= 0xFF000000;
{
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
if (tmp)
*tmp |= 0xFF000000;
}
}
/* Skip padding */

View File

@ -112,7 +112,7 @@ static const INT16 ima_step_size_table[] =
};
static UINT16 dsp_decode_ima_adpcm_sample(ADPCM* adpcm,
int channel, BYTE sample)
unsigned int channel, BYTE sample)
{
INT32 ss;
INT32 d;

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -179,8 +180,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
BYTE* src_ptr; /* used while copying compressed data */
BYTE* cptr; /* points to next byte in cbuf */
BYTE cur_byte; /* last byte fetched from cbuf */
int bits_left; /* bits left in d34 for processing */
int cur_bits_left; /* bits left in cur_byte for processing */
unsigned int bits_left; /* bits left in d34 for processing */
unsigned int cur_bits_left; /* bits left in cur_byte for processing */
int tmp;
UINT32 i32;
@ -330,6 +331,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
tmp = 32 - bits_left;
while (tmp)
@ -338,7 +340,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -527,6 +529,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -535,7 +539,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -769,6 +773,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -777,7 +783,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -990,6 +996,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -998,7 +1006,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -1322,6 +1330,8 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -1330,7 +1340,7 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -296,7 +297,13 @@ RFX_CONTEXT* rfx_context_new(void)
void rfx_context_free(RFX_CONTEXT* context)
{
free(context->quants);
assert(NULL != context);
assert(NULL != context->priv);
assert(NULL != context->priv->TilePool);
assert(NULL != context->priv->BufferPool);
if (context->quants)
free(context->quants);
ObjectPool_Free(context->priv->TilePool);
@ -583,7 +590,8 @@ void CALLBACK rfx_process_message_tile_work_callback(PTP_CALLBACK_INSTANCE insta
static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* message, wStream* s)
{
int i;
BOOL rc;
int i, close_cnt;
int pos;
BYTE quant;
RFX_TILE* tile;
@ -677,10 +685,28 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
params = (RFX_TILE_PROCESS_WORK_PARAM*) malloc(sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
params = (RFX_TILE_PROCESS_WORK_PARAM*)
malloc(sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
if (!work_objects)
{
if (params)
free(params);
return FALSE;
}
if (!params)
{
if (work_objects)
free(work_objects);
return FALSE;
}
ZeroMemory(work_objects, sizeof(PTP_WORK) * message->numTiles);
ZeroMemory(params, sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
}
/* tiles */
close_cnt = 0;
rc = TRUE;
for (i = 0; i < message->numTiles; i++)
{
tile = message->tiles[i] = (RFX_TILE*) ObjectPool_Take(context->priv->TilePool);
@ -689,7 +715,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (Stream_GetRemainingLength(s) < 6)
{
DEBUG_WARN("RfxMessageTileSet packet too small to read tile %d/%d", i, message->numTiles);
return FALSE;
rc = FALSE;
break;
}
Stream_Read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
@ -697,8 +724,10 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (Stream_GetRemainingLength(s) < blockLen - 6)
{
DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", i, message->numTiles, blockLen);
return FALSE;
DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
i, message->numTiles, blockLen);
rc = FALSE;
break;
}
pos = Stream_GetPosition(s) - 6 + blockLen;
@ -730,6 +759,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = message->tiles[i];
@ -737,6 +768,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
(void*) &params[i], &context->priv->ThreadPoolEnv);
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
@ -748,16 +780,18 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
for (i = 0; i < message->numTiles; i++)
for (i = 0; i < close_cnt; i++)
{
WaitForThreadpoolWorkCallbacks(work_objects[i], FALSE);
CloseThreadpoolWork(work_objects[i]);
}
free(work_objects);
free(params);
}
if (work_objects)
free(work_objects);
if (params)
free(params);
for (i = 0; i < message->numTiles; i++)
{
tile = message->tiles[i];
@ -765,7 +799,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
tile->YData = tile->CbData = tile->CrData = NULL;
}
return TRUE;
return rc;
}
RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length)
@ -1040,7 +1074,7 @@ void CALLBACK rfx_compose_message_tile_work_callback(PTP_CALLBACK_INSTANCE insta
RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
int numRects, BYTE* data, int width, int height, int scanline)
{
int i;
int i, close_cnt;
int xIdx;
int yIdx;
int numTilesX;
@ -1054,6 +1088,9 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
RFX_TILE_COMPOSE_WORK_PARAM* params = NULL;
message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE));
if (!message)
return NULL;
ZeroMemory(message, sizeof(RFX_MESSAGE));
if (context->state == RFX_STATE_SEND_HEADERS)
@ -1084,18 +1121,39 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
numTilesY = (height + 63) / 64;
message->numTiles = numTilesX * numTilesY;
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE) * message->numTiles);
if (message->numTiles)
{
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE*) * message->numTiles);
}
DEBUG_RFX("x: %d y: %d width: %d height: %d scanline: %d BytesPerPixel: %d",
rect->x, rect->y, width, height, scanline, BytesPerPixel);
if (context->priv->UseThreads)
{
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
params = (RFX_TILE_COMPOSE_WORK_PARAM*) malloc(sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
if (message->numTiles)
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
if (!work_objects)
{
free(message);
return NULL;
}
params = (RFX_TILE_COMPOSE_WORK_PARAM*)
malloc(sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
if (!params)
{
if (message->tiles)
free(message->tiles);
free(message);
free(work_objects);
return NULL;
}
ZeroMemory(work_objects, sizeof(PTP_WORK) * message->numTiles);
ZeroMemory(params, sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
}
close_cnt = 0;
for (yIdx = 0; yIdx < numTilesY; yIdx++)
{
for (xIdx = 0; xIdx < numTilesX; xIdx++)
@ -1134,6 +1192,8 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = tile;
@ -1141,6 +1201,7 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
(void*) &params[i], &context->priv->ThreadPoolEnv);
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
@ -1151,11 +1212,11 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
message->tilesDataSize = 0;
for (i = 0; i < message->numTiles; i++)
for (i = 0; i < close_cnt; i++)
{
tile = message->tiles[i];
if (context->priv->UseThreads)
if (context->priv->UseThreads && work_objects)
{
WaitForThreadpoolWorkCallbacks(work_objects[i], FALSE);
CloseThreadpoolWork(work_objects[i]);
@ -1164,11 +1225,11 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
message->tilesDataSize += rfx_tile_length(tile);
}
if (context->priv->UseThreads)
{
if (work_objects)
free(work_objects);
if (params)
free(params);
}
return message;
}

View File

@ -143,6 +143,7 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
if (entry)
return entry;
FreeLibrary(library);
return entry;
}

View File

@ -147,6 +147,8 @@ static int extension_load_plugins(rdpExtension* extension)
fprintf(stderr, "extension_load_plugins: %s entry returns error.\n", path);
continue;
}
DLCLOSE(han);
}
return 0;

View File

@ -164,7 +164,8 @@ BOOL freerdp_connect(freerdp* instance)
StreamPool_Return(rdp->transport->ReceivePool, s);
}
pcap_close(update->pcap_rfx);
update->pcap_rfx = NULL;
status = TRUE;
goto freerdp_connect_finally;
}
@ -306,6 +307,13 @@ BOOL freerdp_disconnect(freerdp* instance)
IFCALL(instance->PostDisconnect, instance);
if (instance->update->pcap_rfx)
{
instance->update->dump_rfx = FALSE;
pcap_close(instance->update->pcap_rfx);
instance->update->pcap_rfx = NULL;
}
return TRUE;
}

View File

@ -365,6 +365,12 @@ BOOL http_response_parse_header(HttpResponse* http_response)
char end_of_header_char;
char c;
if (!http_response)
return FALSE;
if (!http_response->lines)
return FALSE;
if (!http_response_parse_header_status_line(http_response, http_response->lines[0]))
return FALSE;
@ -497,7 +503,11 @@ HttpResponse* http_response_recv(rdpTls* tls)
}
http_response->count = count;
http_response->lines = (char**) malloc(sizeof(char*) * http_response->count);
if (count)
{
http_response->lines = (char**) malloc(sizeof(char*) * http_response->count);
ZeroMemory(http_response->lines, sizeof(char*) * http_response->count);
}
count = 0;
line = strtok((char*) buffer, "\r\n");

View File

@ -433,6 +433,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
if (encrypt_status != SEC_E_OK)
{
fprintf(stderr, "EncryptMessage status: 0x%08X\n", encrypt_status);
free(request_pdu);
return -1;
}

View File

@ -295,6 +295,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(packetCapsResponse);
free(versionCaps);
free(packet);
return FALSE;
}
@ -321,6 +324,10 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected CapabilityType: 0x%08X, Expected TSG_CAPABILITY_TYPE_NAP\n",
tsgCaps->capabilityType);
free(tsgCaps);
free(versionCaps);
free(packetCapsResponse);
free(packet);
return FALSE;
}
@ -396,6 +403,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(versionCaps);
free(packetQuarEncResponse);
free(packet);
return FALSE;
}
@ -433,6 +443,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_CAPS_RESPONSE "
"or TSG_PACKET_TYPE_QUARENC_RESPONSE\n", packet->packetId);
free(packet);
return FALSE;
}
@ -562,7 +573,9 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if ((packet->packetId != TSG_PACKET_TYPE_RESPONSE) || (SwitchValue != TSG_PACKET_TYPE_RESPONSE))
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE\n", packet->packetId);
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE\n",
packet->packetId);
free(packet);
return FALSE;
}
@ -577,6 +590,8 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected Packet Response Flags: 0x%08X, Expected TSG_PACKET_TYPE_QUARREQUEST\n",
packetResponse->flags);
free(packet);
free(packetResponse);
return FALSE;
}
@ -599,7 +614,10 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if (SizeValue != packetResponse->responseDataLen)
{
fprintf(stderr, "Unexpected size value: %d, expected: %d\n", SizeValue, packetResponse->responseDataLen);
fprintf(stderr, "Unexpected size value: %d, expected: %d\n",
SizeValue, packetResponse->responseDataLen);
free(packetResponse);
free(packet);
return FALSE;
}
@ -676,6 +694,7 @@ BOOL TsProxyMakeTunnelCallWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSER
BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
BOOL rc = TRUE;
BYTE* buffer;
UINT32 length;
UINT32 offset;
@ -709,7 +728,9 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if ((packet->packetId != TSG_PACKET_TYPE_MESSAGE_PACKET) || (SwitchValue != TSG_PACKET_TYPE_MESSAGE_PACKET))
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET\n", packet->packetId);
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET\n",
packet->packetId);
free(packet);
return FALSE;
}
@ -777,12 +798,24 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
break;
default:
fprintf(stderr, "TsProxyMakeTunnelCallReadResponse: unexpected message type: %d\n", SwitchValue);
return FALSE;
fprintf(stderr, "TsProxyMakeTunnelCallReadResponse: unexpected message type: %d\n",
SwitchValue);
rc = FALSE;
break;
}
return TRUE;
if (packet)
{
if (packet->tsgPacket.packetMsgResponse)
{
if (packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage)
free(packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage);
free(packet->tsgPacket.packetMsgResponse);
}
free(packet);
}
return rc;
}
BOOL TsProxyMakeTunnelCall(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext,

View File

@ -279,7 +279,7 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance)
int i;
void* sin_addr;
int peer_sockfd;
freerdp_peer* client;
freerdp_peer* client = NULL;
socklen_t peer_addr_size;
struct sockaddr_storage peer_addr;
rdpListener* listener = (rdpListener*) instance->listener;
@ -306,6 +306,8 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance)
continue;
#endif
perror("accept");
if (client)
free(client);
return FALSE;
}

View File

@ -293,7 +293,10 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
@ -482,13 +485,10 @@ BOOL nego_recv_response(rdpNego* nego)
status = nego_recv(nego->transport, s, nego);
if (status < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
if (status < 0)
return FALSE;
return TRUE;
}
@ -714,7 +714,10 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
@ -873,7 +876,10 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);

View File

@ -718,7 +718,7 @@ SECURITY_STATUS credssp_decrypt_public_key_echo(rdpCredssp* credssp)
{
int length;
BYTE* buffer;
ULONG pfQOP;
ULONG pfQOP = 0;
BYTE* public_key1;
BYTE* public_key2;
int public_key_length;
@ -1145,7 +1145,10 @@ int credssp_recv(rdpCredssp* credssp)
if(!ber_read_sequence_tag(s, &length) ||
!ber_read_contextual_tag(s, 0, &length, TRUE) ||
!ber_read_integer(s, &version))
{
Stream_Free(s, TRUE);
return -1;
}
/* [1] negoTokens (NegoData) */
if (ber_read_contextual_tag(s, 1, &length, TRUE) != FALSE)
@ -1155,7 +1158,10 @@ int credssp_recv(rdpCredssp* credssp)
!ber_read_contextual_tag(s, 0, &length, TRUE) || /* [0] negoToken */
!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->negoToken, length);
Stream_Read(s, credssp->negoToken.pvBuffer, length);
credssp->negoToken.cbBuffer = length;
@ -1166,7 +1172,10 @@ int credssp_recv(rdpCredssp* credssp)
{
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->authInfo, length);
Stream_Read(s, credssp->authInfo.pvBuffer, length);
credssp->authInfo.cbBuffer = length;
@ -1177,7 +1186,10 @@ int credssp_recv(rdpCredssp* credssp)
{
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->pubKeyAuth, length);
Stream_Read(s, credssp->pubKeyAuth.pvBuffer, length);
credssp->pubKeyAuth.cbBuffer = length;

View File

@ -784,7 +784,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
UINT16 pduType;
UINT16 pduLength;
UINT16 pduSource;
UINT16 channelId;
UINT16 channelId = 0;
UINT16 securityFlags;
int nextPosition;

View File

@ -64,10 +64,19 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
/* colorTable */
if (icon_info->colorTable == NULL)
icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
else
{
if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
}
else if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) realloc(icon_info->colorTable, icon_info->cbColorTable);
Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable);
else
{
free(icon_info->colorTable);
icon_info->colorTable = NULL;
}
if (icon_info->colorTable)
Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable);
/* bitsColor */
if (icon_info->bitsColor == NULL)

View File

@ -115,10 +115,16 @@ static void* base64_decode(BYTE* s, int length, int* data_len)
n[3] = base64_decode_char(*p++);
if ((n[0] == -1) || (n[1] == -1))
{
free(data);
return NULL;
}
if ((n[2] == -1) && (n[3] != -1))
{
free(data);
return NULL;
}
q[0] = (n[0] << 2) + (n[1] >> 4);

View File

@ -392,11 +392,31 @@ char* crypto_cert_subject_common_name(X509* xcert, int* length)
return (char*) common_name;
}
FREERDP_API void crypto_cert_subject_alt_name_free(int count, int *lengths,
char** alt_name)
{
int i;
if (lengths)
free(lengths);
if (alt_name)
{
for (i=0; i<count; i++)
{
if (alt_name[i])
OPENSSL_free(alt_name[i]);
}
free(alt_name);
}
}
char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
{
int index;
int length;
char** strings;
int length = 0;
char** strings = NULL;
BYTE* string;
int num_subject_alt_names;
GENERAL_NAMES* subject_alt_names;
@ -409,8 +429,11 @@ char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
return NULL;
num_subject_alt_names = sk_GENERAL_NAME_num(subject_alt_names);
strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int*) * num_subject_alt_names);
if (num_subject_alt_names)
{
strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int) * num_subject_alt_names);
}
for (index = 0; index < num_subject_alt_names; ++index)
{

View File

@ -34,6 +34,13 @@ void er_read_length(wStream* s, int* length)
Stream_Read_UINT8(s, byte);
if (!length)
return;
*length = 0;
if (!s)
return;
if (byte & 0x80)
{
byte &= ~(0x80);
@ -236,7 +243,7 @@ int er_skip_sequence_tag(int length)
BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
{
int length;
int length = 0;
er_read_universal_tag(s, ER_TAG_ENUMERATED, FALSE);
er_read_length(s, &length);
@ -320,7 +327,7 @@ int er_skip_octet_string(int length)
BOOL er_read_BOOL(wStream* s, BOOL* value)
{
int length;
int length = 0;
BYTE v;
if (!er_read_universal_tag(s, ER_TAG_BOOLEAN, FALSE))
@ -348,7 +355,7 @@ void er_write_BOOL(wStream* s, BOOL value)
BOOL er_read_integer(wStream* s, UINT32* value)
{
int length;
int length = 0;
er_read_universal_tag(s, ER_TAG_INTEGER, FALSE);
er_read_length(s, &length);

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <assert.h>
#include <winpr/crt.h>
#include <winpr/sspi.h>
@ -689,6 +691,10 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
free(common_name);
#endif
if (alt_names)
crypto_cert_subject_alt_name_free(alt_names_count, alt_names_lengths,
alt_names);
return verification_status;
}
@ -712,6 +718,9 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
{
int index;
assert(NULL != hostname);
assert(NULL != common_name);
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@ WARNING: CERTIFICATE NAME MISMATCH! @\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
@ -721,11 +730,13 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
fprintf(stderr, "\t%s\n", common_name ? common_name : "no CN found in certificate");
if (alt_names_count > 1)
{
assert(NULL != alt_names);
fprintf(stderr, "Alternative names:\n");
if (alt_names_count > 1)
{
for (index = 0; index < alt_names_count; index++)
{
assert(alt_names[index]);
fprintf(stderr, "\t %s\n", alt_names[index]);
}
}

View File

@ -143,6 +143,9 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -204,6 +207,9 @@ static int BitBlt_NOTSRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -251,6 +257,9 @@ static int BitBlt_SRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -276,6 +285,9 @@ static int BitBlt_NOTSRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -301,6 +313,9 @@ static int BitBlt_SRCINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -326,6 +341,9 @@ static int BitBlt_SRCAND_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -351,6 +369,9 @@ static int BitBlt_SRCPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -379,6 +400,9 @@ static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT16 color16;
HGDI_BITMAP hSrcBmp;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & P) | (~S & D) */
/* DSPDxax, used to draw glyphs */
@ -420,6 +444,9 @@ static int BitBlt_PSDPxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT16* patp;
UINT16 color16;
if (!hdcSrc || !hdcDest)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -473,6 +500,9 @@ static int BitBlt_SPna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -548,6 +578,9 @@ static int BitBlt_DSna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -575,6 +608,9 @@ static int BitBlt_MERGECOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -601,6 +637,9 @@ static int BitBlt_MERGEPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -732,6 +771,9 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -754,6 +796,9 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
{
if (!hdcDest)
return 0;
if (hdcSrc != NULL)
{
if (gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc) == 0)
@ -766,7 +811,10 @@ int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
}
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -160,6 +160,9 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcDest || !hdcSrc)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -220,7 +223,10 @@ static int BitBlt_NOTSRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
int x, y;
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -267,7 +273,10 @@ static int BitBlt_SRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
int x, y;
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -292,7 +301,10 @@ static int BitBlt_NOTSRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
int x, y;
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -317,7 +329,10 @@ static int BitBlt_SRCINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
int x, y;
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -342,7 +357,10 @@ static int BitBlt_SRCAND_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
int x, y;
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -368,6 +386,9 @@ static int BitBlt_SRCPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -398,6 +419,9 @@ static int BitBlt_DSPDxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32 color32;
HGDI_BITMAP hSrcBmp;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & P) | (~S & D) */
color32 = gdi_get_color_32bpp(hdcDest, hdcDest->textColor);
@ -460,6 +484,9 @@ static int BitBlt_PSDPxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32* patp;
UINT32 color32;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -514,6 +541,9 @@ static int BitBlt_SPDSxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32* patp;
UINT32 color32;
if (!hdcDest || !hdcSrc)
return 1;
/* D = S ^ (P & (D ^ S)) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -566,7 +596,10 @@ static int BitBlt_SPna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT32* srcp;
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -594,6 +627,9 @@ static int BitBlt_DSna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -670,6 +706,9 @@ static int BitBlt_MERGECOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -697,6 +736,9 @@ static int BitBlt_MERGEPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -827,7 +869,10 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT32* srcp;
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -850,6 +895,9 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
{
if (!hdcDest)
return 0;
if (hdcSrc != NULL)
{
if (gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc) == 0)
@ -862,7 +910,10 @@ int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
}
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -88,6 +88,9 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -149,6 +152,9 @@ static int BitBlt_NOTSRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -196,6 +202,9 @@ static int BitBlt_SRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -221,6 +230,9 @@ static int BitBlt_NOTSRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -246,6 +258,9 @@ static int BitBlt_SRCINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -271,6 +286,9 @@ static int BitBlt_SRCAND_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidt
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -296,6 +314,9 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -317,6 +338,9 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
static int BitBlt_DSPDxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
{
if (!hdcSrc || !hdcDest)
return 1;
/* TODO: Implement 8bpp DSPDxax BitBlt */
return 0;
}
@ -329,6 +353,9 @@ static int BitBlt_PSDPxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
BYTE* patp;
BYTE color8;
if (!hdcSrc || !hdcDest)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -382,6 +409,9 @@ static int BitBlt_SPna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -461,6 +491,9 @@ static int BitBlt_DSna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -487,6 +520,9 @@ static int BitBlt_MERGECOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -515,6 +551,9 @@ static int BitBlt_MERGEPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -646,6 +685,9 @@ static int BitBlt_PATPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -682,7 +724,10 @@ int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight
}
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -93,8 +93,11 @@ rdpIconCache* icon_cache_new(rdpRail* rail)
for (i = 0; i < cache->numCaches; i++)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIconCache));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIconCache));
if (cache->numCacheEntries)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIcon));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIcon));
}
}
}

View File

@ -218,4 +218,6 @@ void pcap_close(rdpPcap* pcap)
if (pcap->fp != NULL)
fclose(pcap->fp);
free(pcap);
}

View File

@ -70,7 +70,8 @@ void profiler_print(PROFILER* profiler)
double elapsed_sec = stopwatch_get_elapsed_time_in_seconds(profiler->stopwatch);
double avg_sec = elapsed_sec / (double) profiler->stopwatch->count;
fprintf(stderr, "| %-30.30s| %10lu | %9f | %9f |\n", profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec);
fprintf(stderr, "| %-30.30s| %10lu | %9f | %9f |\n",
profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec);
}
void profiler_print_footer()

View File

@ -658,8 +658,6 @@ static void* test_peer_mainloop(void* arg)
testPeerContext* context;
freerdp_peer* client = (freerdp_peer*) arg;
memset(rfds, 0, sizeof(rfds));
test_peer_init(client);
/* Initialize the real server settings here */
@ -694,6 +692,7 @@ static void* test_peer_mainloop(void* arg)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");
@ -779,12 +778,11 @@ static void test_server_mainloop(freerdp_listener* instance)
void* rfds[32];
fd_set rfds_set;
memset(rfds, 0, sizeof(rfds));
while (1)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -42,8 +42,6 @@ void* xf_server_thread(void* param)
xfServer* server;
freerdp_listener* listener;
ZeroMemory(rfds, sizeof(rfds));
server = (xfServer*) param;
listener = server->listener;
@ -51,6 +49,7 @@ void* xf_server_thread(void* param)
{
rcount = 0;
ZeroMemory(rfds, sizeof(rfds));
if (listener->GetFileDescriptor(listener, rfds, &rcount) != TRUE)
{
fprintf(stderr, "Failed to get FreeRDP file descriptor\n");

View File

@ -475,9 +475,9 @@ typedef struct _wEventType wEventType;
#define DEFINE_EVENT_END(_name) \
} _name ## EventArgs; \
DEFINE_EVENT_HANDLER(_name); \
DEFINE_EVENT_RAISE(_name); \
DEFINE_EVENT_SUBSCRIBE(_name); \
DEFINE_EVENT_UNSUBSCRIBE(_name);
DEFINE_EVENT_RAISE(_name) \
DEFINE_EVENT_SUBSCRIBE(_name) \
DEFINE_EVENT_UNSUBSCRIBE(_name)
#define DEFINE_EVENT_ENTRY(_name) \
{ #_name, { sizeof( _name ## EventArgs) }, 0, { \

View File

@ -156,7 +156,7 @@
/* Mac OS X (__MACOSX__) */
#if (__APPLE__ && __MACH__)
#if (defined(__APPLE__) && defined(__MACH__))
#ifndef __MACOSX__
#define __MACOSX__ 1
#endif
@ -164,7 +164,7 @@
/* iOS (__IOS__)*/
#if (__APPLE__ && TARGET_OS_IPHONE)
#if (defined(__APPLE__) && defined(TARGET_OS_IPHONE))
#ifndef __IOS__
#define __IOS__ 1
#endif

View File

@ -159,22 +159,23 @@ LPSTR CharUpperA(LPSTR lpsz)
int i;
int length;
length = strlen(lpsz);
if (!lpsz)
return NULL;
length = strlen(lpsz);
if (length < 1)
return (LPSTR) NULL;
if (length == 1)
{
LPSTR pc = NULL;
char c = *lpsz;
if ((c >= 'a') && (c <= 'z'))
c = c - 32;
*pc = c;
*lpsz = c;
return pc;
return lpsz;
}
for (i = 0; i < length; i++)
@ -241,6 +242,9 @@ LPSTR CharLowerA(LPSTR lpsz)
int i;
int length;
if (!lpsz)
return (LPSTR) NULL;
length = strlen(lpsz);
if (length < 1)
@ -248,15 +252,14 @@ LPSTR CharLowerA(LPSTR lpsz)
if (length == 1)
{
LPSTR pc = NULL;
char c = *lpsz;
if ((c >= 'A') && (c <= 'Z'))
c = c + 32;
*pc = c;
*lpsz = c;
return pc;
return lpsz;
}
for (i = 0; i < length; i++)

View File

@ -352,5 +352,11 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
if (status != cbMultiByte)
status = 0;
if ((status <= 0) && allocate)
{
free(*lpMultiByteStr);
*lpMultiByteStr = NULL;
}
return status;
}

View File

@ -205,7 +205,11 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
status = connect(pNamedPipe->clientfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un));
if (status != 0)
{
close(pNamedPipe->clientfd);
free(pNamedPipe);
return INVALID_HANDLE_VALUE;
}
return hNamedPipe;
}
@ -440,13 +444,13 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
if (lstat(pFileSearch->lpPath, &fileStat) < 0)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* stat error */
}
if (S_ISDIR(fileStat.st_mode) == 0)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* not a directory */
}
@ -456,7 +460,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
if (!pFileSearch->pDir)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* failed to open directory */
}
@ -475,6 +479,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
}
}
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE;
}
@ -530,13 +535,20 @@ BOOL FindClose(HANDLE hFindFile)
pFileSearch = (WIN32_FILE_SEARCH*) hFindFile;
free(pFileSearch->lpPath);
free(pFileSearch->lpPattern);
closedir(pFileSearch->pDir);
if (pFileSearch)
{
if (pFileSearch->lpPath)
free(pFileSearch->lpPath);
if (pFileSearch->lpPattern)
free(pFileSearch->lpPattern);
if (pFileSearch->pDir)
closedir(pFileSearch->pDir);
free(pFileSearch);
free(pFileSearch);
return TRUE;
}
return TRUE;
return FALSE;
}
BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)

View File

@ -86,6 +86,9 @@ BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName,
{
LPSTR lpMatch;
if (!lpFileName)
return FALSE;
if (*lpWildcard == '*')
{
/*
@ -314,7 +317,7 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
LPSTR lpY;
size_t cchX;
size_t cchY;
LPSTR lpMatchEnd;
LPSTR lpMatchEnd = NULL;
LPSTR lpSubPattern;
size_t cchSubPattern;
LPSTR lpSubFileName;

View File

@ -48,8 +48,7 @@ BOOL CloseHandle(HANDLE hObject)
WINPR_THREAD* thread;
thread = (WINPR_THREAD*) Object;
free(Object);
free(thread);
return TRUE;
}

View File

@ -33,7 +33,7 @@
* Keyboard Type 4
*/
DWORD KBD4T[128] =
static DWORD KBD4T[128] =
{
KBD4_T00,
KBD4_T01,
@ -165,7 +165,7 @@ DWORD KBD4T[128] =
KBD4_T7F
};
DWORD KBD4X[128] =
static DWORD KBD4X[128] =
{
VK_NONE,
VK_NONE,
@ -301,7 +301,7 @@ DWORD KBD4X[128] =
* Keyboard Type 7
*/
DWORD KBD7T[128] =
static DWORD KBD7T[128] =
{
KBD7_T00,
KBD7_T01,
@ -433,7 +433,7 @@ DWORD KBD7T[128] =
KBD7_T7F
};
DWORD KBD7X[128] =
static DWORD KBD7X[128] =
{
VK_NONE,
VK_NONE,

View File

@ -437,7 +437,7 @@ char* GetVirtualKeyName(DWORD vkcode)
DWORD GetVirtualKeyCodeFromName(const char* vkname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++)
{
@ -453,7 +453,7 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname)
DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++)
{

View File

@ -276,16 +276,22 @@ char* GetCombinedPath(char* basePath, char* subPath)
int length;
HRESULT status;
char* path = NULL;
int basePathLength;
int subPathLength;
char* subPathCpy;
int basePathLength = 0;
int subPathLength = 0;
basePathLength = strlen(basePath);
subPathLength = strlen(subPath);
if (basePath)
basePathLength = strlen(basePath);
if (subPath)
subPathLength = strlen(subPath);
length = basePathLength + subPathLength + 1;
path = (char*) malloc(length + 1);
if (!path)
return NULL;
CopyMemory(path, basePath, basePathLength);
if (basePath)
CopyMemory(path, basePath, basePathLength);
path[basePathLength] = '\0';
PathCchConvertStyleA(path, basePathLength, PATH_STYLE_NATIVE);
@ -293,12 +299,12 @@ char* GetCombinedPath(char* basePath, char* subPath)
if (!subPath)
return path;
subPath = _strdup(subPath);
PathCchConvertStyleA(subPath, subPathLength, PATH_STYLE_NATIVE);
subPathCpy = _strdup(subPath);
PathCchConvertStyleA(subPathCpy, subPathLength, PATH_STYLE_NATIVE);
status = NativePathCchAppendA(path, length + 1, subPath);
status = NativePathCchAppendA(path, length + 1, subPathCpy);
free(subPath);
free(subPathCpy);
return path;
}

View File

@ -65,7 +65,13 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
pWritePipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE));
if (!pReadPipe || !pWritePipe)
{
if (pReadPipe)
free(pReadPipe);
if (pWritePipe)
free(pWritePipe);
return FALSE;
}
pReadPipe->fd = pipe_fd[0];
pWritePipe->fd = pipe_fd[1];

View File

@ -55,6 +55,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Client NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -68,6 +73,10 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Client NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -120,6 +129,8 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure\n");
CloseHandle(hNamedPipe);
return NULL;
}
@ -136,6 +147,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Server NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -152,6 +167,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Server NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -176,6 +195,9 @@ int TestPipeCreateNamedPipe(int argc, char* argv[])
WaitForSingleObject(ClientThread, INFINITE);
WaitForSingleObject(ServerThread, INFINITE);
CloseHandle(ClientThread);
CloseHandle(ServerThread);
return 0;
}

View File

@ -63,6 +63,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -85,6 +90,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -160,6 +170,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure: %d\n", GetLastError());
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -178,6 +192,12 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -203,6 +223,13 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}

View File

@ -31,8 +31,8 @@
#define WINPR_HKLM_HIVE "/etc/winpr/HKLM.reg"
void reg_print_key(Reg* reg, RegKey* key);
void reg_print_value(Reg* reg, RegVal* value);
static void reg_print_key(Reg* reg, RegKey* key);
static void reg_print_value(Reg* reg, RegVal* value);
struct reg_data_type
{
@ -41,7 +41,7 @@ struct reg_data_type
DWORD type;
};
struct reg_data_type REG_DATA_TYPE_TABLE[] =
static struct reg_data_type REG_DATA_TYPE_TABLE[] =
{
{ "\"", 1, REG_SZ },
{ "dword:", 6, REG_DWORD },
@ -55,7 +55,7 @@ struct reg_data_type REG_DATA_TYPE_TABLE[] =
{ NULL, 0, 0 }
};
char* REG_DATA_TYPE_STRINGS[] =
static char* REG_DATA_TYPE_STRINGS[] =
{
"REG_NONE",
"REG_SZ",
@ -71,7 +71,7 @@ char* REG_DATA_TYPE_STRINGS[] =
"REG_QWORD"
};
void reg_load_start(Reg* reg)
static void reg_load_start(Reg* reg)
{
long int file_size;
@ -79,6 +79,10 @@ void reg_load_start(Reg* reg)
file_size = ftell(reg->fp);
fseek(reg->fp, 0, SEEK_SET);
reg->line = NULL;
reg->next_line = NULL;
reg->buffer = NULL;
if (file_size < 1)
return;
@ -87,24 +91,41 @@ void reg_load_start(Reg* reg)
if (fread(reg->buffer, file_size, 1, reg->fp) != 1)
{
free(reg->buffer);
reg->buffer = NULL;
return;
}
reg->buffer[file_size] = '\n';
reg->buffer[file_size + 1] = '\0';
reg->line = NULL;
reg->next_line = strtok(reg->buffer, "\n");
}
void reg_load_finish(Reg* reg)
static void reg_load_finish(Reg* reg)
{
free(reg->buffer);
reg->buffer = NULL;
reg->line = NULL;
if (!reg)
return;
if (reg->buffer)
{
free(reg->buffer);
reg->buffer = NULL;
}
if (reg->line)
{
free(reg->line);
reg->line = NULL;
}
if (reg->next_line)
{
free(reg->next_line);
reg->next_line = NULL;
}
}
RegVal* reg_load_value(Reg* reg, RegKey* key)
static RegVal* reg_load_value(Reg* reg, RegKey* key)
{
int index;
char* p[5];
@ -181,13 +202,19 @@ RegVal* reg_load_value(Reg* reg, RegKey* key)
return value;
}
BOOL reg_load_has_next_line(Reg* reg)
static BOOL reg_load_has_next_line(Reg* reg)
{
if (!reg)
return 0;
return (reg->next_line != NULL) ? 1 : 0;
}
char* reg_load_get_next_line(Reg* reg)
static char* reg_load_get_next_line(Reg* reg)
{
if (!reg)
return NULL;
reg->line = reg->next_line;
reg->next_line = strtok(NULL, "\n");
reg->line_length = strlen(reg->line);
@ -195,12 +222,12 @@ char* reg_load_get_next_line(Reg* reg)
return reg->line;
}
char* reg_load_peek_next_line(Reg* reg)
static char* reg_load_peek_next_line(Reg* reg)
{
return reg->next_line;
}
void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
static void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
{
char* name;
char* path;
@ -226,7 +253,7 @@ void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
free(path);
}
RegKey* reg_load_key(Reg* reg, RegKey* key)
static RegKey* reg_load_key(Reg* reg, RegKey* key)
{
char* p[2];
int length;
@ -300,7 +327,7 @@ void reg_load(Reg* reg)
reg_load_finish(reg);
}
void reg_unload_value(Reg* reg, RegVal* value)
static void reg_unload_value(Reg* reg, RegVal* value)
{
if (value->type == REG_DWORD)
{
@ -318,7 +345,7 @@ void reg_unload_value(Reg* reg, RegVal* value)
free(value);
}
void reg_unload_key(Reg* reg, RegKey* key)
static void reg_unload_key(Reg* reg, RegKey* key)
{
RegVal* pValue;
RegVal* pValueNext;

View File

@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef REGISTRY_REG_H_
#define REGISTRY_REG_H_
#include <winpr/registry.h>
@ -62,3 +64,6 @@ struct _reg_key
};
Reg* reg_open(BOOL read_only);
void reg_close(Reg *reg);
#endif

View File

@ -143,6 +143,10 @@ void NdrProcessParams(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, NDR_P
for (i = 0; i < numberParams; i++)
{
#ifdef __x86_64__
float tmp;
#endif
arg = pStubMsg->StackTop + params[i].StackOffset;
fmt = (PFORMAT_STRING) &pStubMsg->StubDesc->pFormatTypes[params[i].Type.Offset];
@ -151,7 +155,7 @@ void NdrProcessParams(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, NDR_P
!(params[i].Attributes.IsSimpleRef) &&
((params[i].Type.FormatChar) == FC_FLOAT) && !fpuArgs)
{
float tmp = *(double*) arg;
tmp = *(double*) arg;
arg = (unsigned char*) &tmp;
}
#endif

View File

@ -80,6 +80,8 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
if (pStubMsg->StackTop)
ptr = pStubMsg->StackTop;
}
else
return pFormat;
switch (correlation_operator)
{
@ -110,6 +112,9 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
break;
}
if (!ptr)
return pFormat;
switch (type)
{
case FC_LONG:

View File

@ -43,20 +43,21 @@ char* NTLM_PACKAGE_NAME = "NTLM";
void ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
{
char *ws = Workstation;
DWORD nSize = 0;
if (!Workstation)
{
GetComputerNameExA(ComputerNameNetBIOS, NULL, &nSize);
Workstation = malloc(nSize);
GetComputerNameExA(ComputerNameNetBIOS, Workstation, &nSize);
ws = malloc(nSize);
GetComputerNameExA(ComputerNameNetBIOS, ws, &nSize);
}
context->Workstation.Length = ConvertToUnicode(CP_UTF8, 0,
Workstation, -1, &context->Workstation.Buffer, 0) - 1;
ws, -1, &context->Workstation.Buffer, 0) - 1;
context->Workstation.Length *= 2;
if (nSize > 0)
if (!Workstation)
free(Workstation);
}
@ -81,22 +82,23 @@ void ntlm_SetContextServicePrincipalNameA(NTLM_CONTEXT* context, char* ServicePr
void ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
{
char *name = TargetName;
DWORD nSize = 0;
if (!TargetName)
{
GetComputerNameExA(ComputerNameDnsHostname, NULL, &nSize);
TargetName = malloc(nSize);
name = malloc(nSize);
GetComputerNameExA(ComputerNameDnsHostname, TargetName, &nSize);
CharUpperA(TargetName);
}
context->TargetName.cbBuffer = ConvertToUnicode(CP_UTF8, 0,
TargetName, -1, (LPWSTR*) &context->TargetName.pvBuffer, 0) - 1;
name, -1, (LPWSTR*) &context->TargetName.pvBuffer, 0) - 1;
context->TargetName.cbBuffer *= 2;
if (nSize > 0)
free(TargetName);
if (!TargetName)
free(name);
}
NTLM_CONTEXT* ntlm_ContextNew()

View File

@ -279,6 +279,7 @@ void ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)
{
fprintf(stderr, "Error: Could not find user in SAM database\n");
}
SamClose(sam);
}
void ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)

View File

@ -650,6 +650,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
message = &context->AUTHENTICATE_MESSAGE;
ZeroMemory(message, sizeof(NTLM_AUTHENTICATE_MESSAGE));
ZeroMemory(&response, sizeof(NTLMv2_RESPONSE));
s = Stream_New(buffer->pvBuffer, buffer->cbBuffer);
@ -799,6 +800,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
winpr_HexDump(context->MessageIntegrityCheck, 16);
fprintf(stderr, "Actual MIC:\n");
winpr_HexDump(message->MessageIntegrityCheck, 16);
Stream_Free(s, FALSE);
return SEC_E_MESSAGE_ALTERED;
}

View File

@ -128,6 +128,7 @@ void sspi_ContextBufferAllocTableNew()
{
size_t size;
ContextBufferAllocTable.entries = NULL;
ContextBufferAllocTable.cEntries = 0;
ContextBufferAllocTable.cMaxEntries = 4;
@ -144,6 +145,8 @@ void sspi_ContextBufferAllocTableGrow()
ContextBufferAllocTable.cMaxEntries *= 2;
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
if (!size)
return;
ContextBufferAllocTable.entries = realloc(ContextBufferAllocTable.entries, size);
ZeroMemory((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], size / 2);

View File

@ -70,12 +70,14 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
if (event->pipe_fd[0] < 0)
{
fprintf(stderr, "CreateEventW: failed to create event\n");
free(event);
return NULL;
}
#else
if (pipe(event->pipe_fd) < 0)
{
fprintf(stderr, "CreateEventW: failed to create event\n");
free(event);
return NULL;
}
#endif

View File

@ -39,6 +39,8 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
WINPR_SEMAPHORE* semaphore;
semaphore = (WINPR_SEMAPHORE*) malloc(sizeof(WINPR_SEMAPHORE));
if (!semaphore)
return NULL;
semaphore->pipe_fd[0] = -1;
semaphore->pipe_fd[0] = -1;
@ -51,13 +53,19 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
if (pipe(semaphore->pipe_fd) < 0)
{
fprintf(stderr, "CreateSemaphoreW: failed to create semaphore\n");
free(semaphore);
return NULL;
}
while (lInitialCount > 0)
{
if (write(semaphore->pipe_fd[1], "-", 1) != 1)
return FALSE;
{
close(semaphore->pipe_fd[0]);
close(semaphore->pipe_fd[1]);
free(semaphore);
return NULL;
}
lInitialCount--;
}

View File

@ -30,7 +30,9 @@
#include <time.h>
#ifdef HAVE_UNISTD_H
#define _XOPEN_SOURCE 500
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#endif

View File

@ -53,14 +53,20 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
#ifdef HAVE_TIMERFD_H
timer->fd = timerfd_create(CLOCK_MONOTONIC, 0);
if (timer->fd <= 0)
{
free(timer);
return NULL;
}
status = fcntl(timer->fd, F_SETFL, O_NONBLOCK);
if (status)
{
close(timer->fd);
free(timer);
return NULL;
}
#endif
}

View File

@ -90,7 +90,7 @@ defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/sysctl.h>
#endif
DWORD GetProcessorArchitecture()
static DWORD GetProcessorArchitecture()
{
DWORD cpuArch = PROCESSOR_ARCHITECTURE_UNKNOWN;
@ -113,7 +113,7 @@ DWORD GetProcessorArchitecture()
return cpuArch;
}
DWORD GetNumberOfProcessors()
static DWORD GetNumberOfProcessors()
{
DWORD numCPUs = 1;

View File

@ -248,7 +248,7 @@ void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
void* ListDictionary_GetItemValue(wListDictionary* listDictionary, void* key)
{
void* value = NULL;
wListDictionaryItem* item;
wListDictionaryItem* item = NULL;
if (listDictionary->synchronized)
EnterCriticalSection(&listDictionary->lock);

View File

@ -70,8 +70,17 @@ wReference* ReferenceTable_GetFreeEntry(wReferenceTable* referenceTable)
if (!found)
{
if (!referenceTable->size)
{
if (referenceTable->array)
free(referenceTable->array);
referenceTable->array = NULL;
return NULL;
}
referenceTable->size *= 2;
referenceTable->array = (wReference*) realloc(referenceTable->array, sizeof(wReference) * referenceTable->size);
referenceTable->array = (wReference*) realloc(referenceTable->array,
sizeof(wReference) * referenceTable->size);
ZeroMemory(&referenceTable->array[(referenceTable->size / 2)],
sizeof(wReference) * (referenceTable->size / 2));

View File

@ -286,6 +286,7 @@ WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPWSTR User, UINT32 UserLength,
DomainMatch = 1;
}
}
free(EntryDomain);
}
else
{

View File

@ -7855,3 +7855,4 @@ TRIO_ARGS1((errorcode),
#ifdef _WIN32
#pragma warning(pop)
#endif

View File

@ -27,6 +27,11 @@ include_directories(${OPENSSL_INCLUDE_DIR})
add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS})
# This line compiles the static libraries with -fPIC to allow linking
# to shared libraries later on...
# TODO: Remove this non portable way of linking.
set_target_properties(${MODULE_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
set(${MODULE_PREFIX}_LIBS
${ZLIB_LIBRARIES}
${OPENSSL_LIBRARIES})