Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Dorian Johnson 2012-05-17 09:32:27 -05:00
commit 05cfd14cb9
9 changed files with 84 additions and 16 deletions

View File

@ -67,7 +67,7 @@ wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data)
wfBitmap* image;
hdc = GetDC(NULL);
image = (wfBitmap*) malloc(sizeof(wfBitmap));
image = (wfBitmap*) xmalloc(sizeof(wfBitmap));
image->hdc = CreateCompatibleDC(hdc);
if (data == NULL)
@ -87,7 +87,7 @@ wfBitmap* wf_bitmap_new(wfInfo* wfi, int width, int height, int bpp, uint8* data
wfBitmap* bitmap;
hdc = GetDC(NULL);
bitmap = (wfBitmap*) malloc(sizeof(wfBitmap));
bitmap = (wfBitmap*) xmalloc(sizeof(wfBitmap));
bitmap->hdc = CreateCompatibleDC(hdc);
bitmap->bitmap = wf_create_dib(wfi, width, height, bpp, data, &(bitmap->pdata));
bitmap->org_bitmap = (HBITMAP) SelectObject(bitmap->hdc, bitmap->bitmap);

View File

@ -296,12 +296,12 @@ boolean wf_post_connect(freerdp* instance)
wfi->hdc->alpha = wfi->clrconv->alpha;
wfi->hdc->invert = wfi->clrconv->invert;
wfi->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND));
wfi->hdc->hwnd = (HGDI_WND) xmalloc(sizeof(GDI_WND));
wfi->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0);
wfi->hdc->hwnd->invalid->null = 1;
wfi->hdc->hwnd->count = 32;
wfi->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count);
wfi->hdc->hwnd->cinvalid = (HGDI_RGN) xmalloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count);
wfi->hdc->hwnd->ninvalid = 0;
wfi->image = wf_bitmap_new(wfi, 64, 64, 32, NULL);

View File

@ -488,7 +488,8 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32);
stream_seek(s, 32);
snprintf(settings->client_hostname, sizeof(settings->client_hostname), "%s", str);
snprintf(settings->client_hostname, 31, "%s", str);
settings->client_hostname[31] = 0;
xfree(str);
stream_read_uint32(s, settings->kbd_type); /* keyboardType */
@ -1208,4 +1209,3 @@ void gcc_write_client_monitor_data(STREAM* s, rdpSettings* settings)
}
}
}

View File

@ -128,7 +128,7 @@ boolean ntlm_authenticate(rdpNtlm* ntlm)
if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK)
{
printf("QueryContextAttributes SECPKG_ATTR_SIZES failure\n");
return 0;
return false ;
}
if (status == SEC_I_COMPLETE_NEEDED)
@ -491,6 +491,8 @@ int rpc_recv_bind_ack_pdu(rdpRpc* rpc)
int pdu_length = 0x8FFF;
pdu = xmalloc(pdu_length);
if (pdu == NULL)
return -1 ;
status = rpc_out_read(rpc, pdu, pdu_length);
if (status > 0)
@ -502,6 +504,11 @@ int rpc_recv_bind_ack_pdu(rdpRpc* rpc)
stream_free(s);
auth_data = xmalloc(header.auth_length);
if (auth_data == NULL)
{
xfree(pdu) ;
return -1 ;
}
p = (pdu + (header.frag_length - header.auth_length));
memcpy(auth_data, p, header.auth_length);
@ -581,6 +588,11 @@ int rpc_out_read(rdpRpc* rpc, uint8* data, int length)
rts_send_flow_control_ack_pdu(rpc); /* Send FlowControlAck every time AvailableWindow reaches the half */
pdu = xmalloc(0xFFFF);
if (pdu == NULL)
{
printf("rpc_out_read error: memory allocation failed") ;
return -1 ;
}
status = tls_read(rpc->tls_out, pdu, 16); /* read first 16 bytes to get RPC PDU Header */
@ -610,6 +622,7 @@ int rpc_out_read(rdpRpc* rpc, uint8* data, int length)
if (header.ptype == PTYPE_RTS) /* RTS PDU */
{
printf("rpc_out_read error: Unexpected RTS PDU\n");
xfree(pdu);
return -1;
}
else
@ -622,6 +635,7 @@ int rpc_out_read(rdpRpc* rpc, uint8* data, int length)
if (length < header.frag_length)
{
printf("rpc_out_read error! receive buffer is not large enough\n");
xfree(pdu);
return -1;
}
@ -634,7 +648,6 @@ int rpc_out_read(rdpRpc* rpc, uint8* data, int length)
#endif
xfree(pdu);
return header.frag_length;
}
@ -758,11 +771,18 @@ int rpc_read(rdpRpc* rpc, uint8* data, int length)
int rpc_length = length + 0xFF;
uint8* rpc_data = xmalloc(rpc_length);
if (rpc_data == NULL)
{
printf("rpc_read error: memory allocation failed\n") ;
return -1 ;
}
if (rpc->read_buffer_len > 0)
{
if (rpc->read_buffer_len > (uint32) length)
{
printf("rpc_read error: receiving buffer is not large enough\n");
xfree(rpc_data) ;
return -1;
}
@ -824,7 +844,6 @@ int rpc_read(rdpRpc* rpc, uint8* data, int length)
}
xfree(rpc_data);
return read;
}
@ -845,7 +864,7 @@ boolean rpc_connect(rdpRpc* rpc)
return false;
}
if (!rpc_recv_bind_ack_pdu(rpc))
if (rpc_recv_bind_ack_pdu(rpc) <= 0)
{
printf("rpc_recv_bind_ack_pdu error!\n");
return false;

View File

@ -174,7 +174,8 @@ rdpSettings* settings_new(void* instance)
settings->frame_acknowledge = 2;
settings->uniconv = freerdp_uniconv_new();
gethostname(settings->client_hostname, sizeof(settings->client_hostname) - 1);
gethostname(settings->client_hostname, 31);
settings->client_hostname[31] = 0;
settings->mouse_motion = true;
settings->client_auto_reconnect_cookie = xnew(ARC_CS_PRIVATE_PACKET);

View File

@ -1730,11 +1730,17 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
length = 0x8FFF;
data = xmalloc(length);
if (data == NULL)
{
printf("rpc_recv - memory allocation error\n") ;
return false ;
}
status = rpc_read(rpc, data, length);
if (status <= 0)
{
printf("rpc_recv failed!\n");
xfree(data) ;
return false;
}
@ -1765,6 +1771,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
if (status <= 0)
{
printf("rpc_write opnum=2 failed!\n");
xfree(data) ;
return false;
}
@ -1773,6 +1780,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
if (status <= 0)
{
printf("rpc_recv failed!\n");
xfree(data) ;
return false;
}
@ -1831,6 +1839,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
if (status <= 0)
{
printf("rpc_write opnum=4 failed!\n");
xfree(data) ;
return false;
}
xfree(dest_addr_unic);
@ -1840,6 +1849,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
if (status < 0)
{
printf("rpc_recv failed!\n");
xfree(data) ;
return false;
}
@ -1867,9 +1877,11 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
if (status <= 0)
{
printf("rpc_write opnum=8 failed!\n");
xfree(data) ;
return false;
}
xfree(data) ;
return true;
}
#else

View File

@ -1605,9 +1605,9 @@ void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone)
#ifdef HAVE_TM_GMTOFF
if (local_time->tm_gmtoff >= 0)
clientTimeZone->bias = (uint32) (local_time->tm_gmtoff / 60);
clientTimeZone->bias = (uint32) (-1 * local_time->tm_gmtoff / 60);
else
clientTimeZone->bias = (uint32) ((-1 * local_time->tm_gmtoff) / 60 + 720);
clientTimeZone->bias = (uint32) ((-1 * local_time->tm_gmtoff) / 60);
#elif sun
if (local_time->tm_isdst > 0)
clientTimeZone->bias = (uint32) (altzone / 3600);

View File

@ -266,8 +266,8 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing client hostname\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
strncpy(settings->client_hostname, argv[index], sizeof(settings->client_hostname) - 1);
settings->client_hostname[sizeof(settings->client_hostname) - 1] = 0;
strncpy(settings->client_hostname, argv[index], 31);
settings->client_hostname[31] = 0;
}
else if (strcmp("-o", argv[index]) == 0)
{

View File

@ -1,4 +1,4 @@
/**
/*
* FreeRDP: A Remote Desktop Protocol Client
* Stream Utils
*
@ -24,6 +24,23 @@
#include <freerdp/utils/memory.h>
#include <freerdp/utils/stream.h>
/**
* Allocates and initializes a STREAM structure.
* STREAM are used to ease data access in read and write operations.
* They consist of a buffer containing the data we want to access, and an offset associated to it, and keeping
* track of the 'current' position in the stream. A list of functions can then be used to read/write different
* type of data to/from it.
* @see stream.h for the list of data access functions.
*
* @param size [in] - size of the buffer that will ba allocated to the stream.
* If 0, there will be no buffer attached to the stream. The caller
* then needs to call stream_attach() to link an existing buffer to this stream.
* Caution: calling stream_attach() on a stream with an existing buffer will result
* in this buffer being lost, and possible memory leak.
*
* @return A pointer to an allocated and initialized STREAM structure.
* This pointer need to be deallocated using the stream_free() function.
*/
STREAM* stream_new(int size)
{
STREAM* stream;
@ -44,6 +61,15 @@ STREAM* stream_new(int size)
return stream;
}
/**
* This function is used to deallocate a stream that was allocated using stream_new().
* Caution: the buffer linked to the stream will be deallocated in the process. If this buffer was attached
* using the stream_attach() function, the stream_detach() function needs to be called before calling stream_free()
* otherwise it will be freed in the process.
*
* @param stream [in] - Pointer to the STREAM structure that needs to be deallocated.
* This pointer is invalid on return.
*/
void stream_free(STREAM* stream)
{
if (stream != NULL)
@ -55,6 +81,16 @@ void stream_free(STREAM* stream)
}
}
/**
* This function is used to extend the size of an existing stream.
* It will infact extend the attached buffer, fill the newly allocated region with 0, and reset the current
* stream position.
* If the stream did not have a buffer attached, a new one will be allocated and attached.
*
* @param stream [in/out] pointer to the STREAM structure that needs to be extended.
* @param request_size [in] Number of bytes to add to the existing stream.
* If the value is < the existing size, then the existing size is doubled.
*/
void stream_extend(STREAM* stream, int request_size)
{
int pos;