Skip to content

Commit

Permalink
libfreerdp-utils: purge old string utils
Browse files Browse the repository at this point in the history
  • Loading branch information
awakecoding committed Mar 22, 2013
1 parent 27dc85b commit 93a752b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 122 deletions.
47 changes: 0 additions & 47 deletions include/freerdp/utils/string.h

This file was deleted.

65 changes: 46 additions & 19 deletions libfreerdp/core/redirection.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,40 @@ void rdp_print_redirection_flags(UINT32 flags)
printf("}\n");
}

BOOL rdp_string_read_length32(wStream* s, rdpString* string)
{
if(stream_get_left(s) < 4)
return FALSE;

stream_read_UINT32(s, string->length);

if(stream_get_left(s) < string->length)
return FALSE;

string->unicode = (char*) malloc(string->length);
stream_read(s, string->unicode, string->length);

ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) string->unicode, string->length / 2, &string->ascii, 0, NULL, NULL);

return TRUE;
}

void rdp_string_free(rdpString* string)
{
if (string->unicode != NULL)
free(string->unicode);

if (string->ascii != NULL)
free(string->ascii);
}

BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
{
UINT16 flags;
UINT16 length;
rdpRedirection* redirection = rdp->redirection;

if(stream_get_left(s) < 12)
if (stream_get_left(s) < 12)
return FALSE;
stream_read_UINT16(s, flags); /* flags (2 bytes) */
stream_read_UINT16(s, length); /* length (2 bytes) */
Expand All @@ -82,17 +109,17 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)

if (redirection->flags & LB_TARGET_NET_ADDRESS)
{
if(!freerdp_string_read_length32(s, &redirection->targetNetAddress))
if (!rdp_string_read_length32(s, &redirection->targetNetAddress))
return FALSE;
DEBUG_REDIR("targetNetAddress: %s", redirection->targetNetAddress.ascii);
}

if (redirection->flags & LB_LOAD_BALANCE_INFO)
{
if(stream_get_left(s) < 4)
if (stream_get_left(s) < 4)
return FALSE;
stream_read_UINT32(s, redirection->LoadBalanceInfoLength);
if(stream_get_left(s) < redirection->LoadBalanceInfoLength)
if (stream_get_left(s) < redirection->LoadBalanceInfoLength)
return FALSE;

redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength);
Expand All @@ -105,22 +132,22 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)

if (redirection->flags & LB_USERNAME)
{
if(!freerdp_string_read_length32(s, &redirection->username))
if (!rdp_string_read_length32(s, &redirection->username))
return FALSE;
DEBUG_REDIR("username: %s", redirection->username.ascii);
}

if (redirection->flags & LB_DOMAIN)
{
if(!freerdp_string_read_length32(s, &redirection->domain))
if (!rdp_string_read_length32(s, &redirection->domain))
return FALSE;
DEBUG_REDIR("domain: %s", redirection->domain.ascii);
}

if (redirection->flags & LB_PASSWORD)
{
/* Note: length (hopefully) includes double zero termination */
if(stream_get_left(s) < 4)
if (stream_get_left(s) < 4)
return FALSE;
stream_read_UINT32(s, redirection->PasswordCookieLength);
redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength);
Expand All @@ -134,21 +161,21 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)

if (redirection->flags & LB_TARGET_FQDN)
{
if(!freerdp_string_read_length32(s, &redirection->targetFQDN))
if (!rdp_string_read_length32(s, &redirection->targetFQDN))
return FALSE;
DEBUG_REDIR("targetFQDN: %s", redirection->targetFQDN.ascii);
}

if (redirection->flags & LB_TARGET_NETBIOS_NAME)
{
if(!freerdp_string_read_length32(s, &redirection->targetNetBiosName))
if (!rdp_string_read_length32(s, &redirection->targetNetBiosName))
return FALSE;
DEBUG_REDIR("targetNetBiosName: %s", redirection->targetNetBiosName.ascii);
}

if (redirection->flags & LB_CLIENT_TSV_URL)
{
if(!freerdp_string_read_length32(s, &redirection->tsvUrl))
if (!rdp_string_read_length32(s, &redirection->tsvUrl))
return FALSE;
DEBUG_REDIR("tsvUrl: %s", redirection->tsvUrl.ascii);
}
Expand All @@ -159,7 +186,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
UINT32 count;
UINT32 targetNetAddressesLength;

if(stream_get_left(s) < 8)
if (stream_get_left(s) < 8)
return FALSE;
stream_read_UINT32(s, targetNetAddressesLength);

Expand All @@ -171,7 +198,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)

for (i = 0; i < (int) count; i++)
{
if(!freerdp_string_read_length32(s, &redirection->targetNetAddresses[i]))
if (!rdp_string_read_length32(s, &redirection->targetNetAddresses[i]))
return FALSE;
DEBUG_REDIR("targetNetAddresses: %s", (&redirection->targetNetAddresses[i])->ascii);
}
Expand Down Expand Up @@ -216,12 +243,12 @@ void redirection_free(rdpRedirection* redirection)
{
if (redirection != NULL)
{
freerdp_string_free(&redirection->tsvUrl);
freerdp_string_free(&redirection->username);
freerdp_string_free(&redirection->domain);
freerdp_string_free(&redirection->targetFQDN);
freerdp_string_free(&redirection->targetNetBiosName);
freerdp_string_free(&redirection->targetNetAddress);
rdp_string_free(&redirection->tsvUrl);
rdp_string_free(&redirection->username);
rdp_string_free(&redirection->domain);
rdp_string_free(&redirection->targetFQDN);
rdp_string_free(&redirection->targetNetBiosName);
rdp_string_free(&redirection->targetNetAddress);

if (redirection->LoadBalanceInfo)
free(redirection->LoadBalanceInfo);
Expand All @@ -234,7 +261,7 @@ void redirection_free(rdpRedirection* redirection)
int i;

for (i = 0; i < (int) redirection->targetNetAddressesCount; i++)
freerdp_string_free(&redirection->targetNetAddresses[i]);
rdp_string_free(&redirection->targetNetAddresses[i]);

free(redirection->targetNetAddresses);
}
Expand Down
9 changes: 8 additions & 1 deletion libfreerdp/core/redirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@

#include <freerdp/freerdp.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/string.h>

#include <winpr/stream.h>

struct rdp_string
{
char* ascii;
char* unicode;
UINT32 length;
};
typedef struct rdp_string rdpString;

struct rdp_redirection
{
UINT32 flags;
Expand Down
1 change: 0 additions & 1 deletion libfreerdp/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ set(${MODULE_PREFIX}_SRCS
rail.c
signal.c
stopwatch.c
string.c
svc_plugin.c
tcp.c
time.c
Expand Down
1 change: 0 additions & 1 deletion libfreerdp/utils/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <freerdp/types.h>
#include <freerdp/settings.h>
#include <freerdp/utils/string.h>

#ifndef _WIN32
#include <unistd.h>
Expand Down
53 changes: 0 additions & 53 deletions libfreerdp/utils/string.c

This file was deleted.

0 comments on commit 93a752b

Please sign in to comment.