libfreerdp-utils: purge old string utils
This commit is contained in:
parent
27dc85bed9
commit
93a752b546
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* String Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_UTILS_STRING_H
|
||||
#define FREERDP_UTILS_STRING_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
|
||||
#include <winpr/stream.h>
|
||||
|
||||
struct rdp_string
|
||||
{
|
||||
char* ascii;
|
||||
char* unicode;
|
||||
UINT32 length;
|
||||
};
|
||||
typedef struct rdp_string rdpString;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API BOOL freerdp_string_read_length32(wStream* s, rdpString* string);
|
||||
FREERDP_API void freerdp_string_free(rdpString* string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_UTILS_STRING_H */
|
@ -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) */
|
||||
@ -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);
|
||||
@ -105,14 +132,14 @@ 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);
|
||||
}
|
||||
@ -120,7 +147,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
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);
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -29,7 +29,6 @@ set(${MODULE_PREFIX}_SRCS
|
||||
rail.c
|
||||
signal.c
|
||||
stopwatch.c
|
||||
string.c
|
||||
svc_plugin.c
|
||||
tcp.c
|
||||
time.c
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/utils/string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* String Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#include <freerdp/utils/string.h>
|
||||
|
||||
BOOL freerdp_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 freerdp_string_free(rdpString* string)
|
||||
{
|
||||
if (string->unicode != NULL)
|
||||
free(string->unicode);
|
||||
|
||||
if (string->ascii != NULL)
|
||||
free(string->ascii);
|
||||
}
|
Loading…
Reference in New Issue
Block a user