libfreerdp-utils: get rid of xstrdup in favor of WinPR _strdup

This commit is contained in:
Marc-André Moreau 2012-10-08 23:42:01 -04:00
parent 9909a12af5
commit 2df7aaad39
29 changed files with 144 additions and 132 deletions

View File

@ -36,9 +36,9 @@ add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
if(MONOLITHIC_BUILD)
target_link_libraries(${MODULE_NAME} freerdp)
target_link_libraries(${MODULE_NAME} freerdp winpr)
else()
target_link_libraries(${MODULE_NAME} freerdp-utils)
target_link_libraries(${MODULE_NAME} freerdp-utils winpr-crt)
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -25,6 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <freerdp/types.h>
#include <freerdp/constants.h>
#include <freerdp/utils/hexdump.h>
@ -138,7 +141,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3
if (ascii)
{
format_name->name = xstrdup((char*) s->p);
format_name->name = _strdup((char*) s->p);
format_name->length = strlen(format_name->name);
}
else

View File

@ -718,7 +718,7 @@ const int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
if( path[0] == '%' )
{
_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
disk_register_disk_path(pEntryPoints, name, xstrdup(buf));
disk_register_disk_path(pEntryPoints, name, _strdup(buf));
}
else if( path[0] == '*' )
{
@ -738,7 +738,7 @@ const int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
buf[len + 1] = dev[0];
buf[len + 2] = 0;
buf[len + 3] = 0;
disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev));
disk_register_disk_path(pEntryPoints, _strdup(buf), _strdup(dev));
}
}
}

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <freerdp/utils/memory.h>
@ -108,7 +109,7 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr,
listener = xnew(DVCMAN_LISTENER);
listener->iface.GetConfiguration = dvcman_get_configuration;
listener->dvcman = dvcman;
listener->channel_name = xstrdup(pszChannelName);
listener->channel_name = _strdup(pszChannelName);
listener->flags = ulFlags;
listener->listener_callback = pListenerCallback;

View File

@ -29,6 +29,8 @@
#include <time.h>
#include <cups/cups.h>
#include <winpr/crt.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/channels/rdpdr.h>
@ -152,7 +154,7 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, uint32 id)
#ifndef _CUPS_API_1_4
cups_printjob->printjob_object = xstrdup(tmpnam(NULL));
cups_printjob->printjob_object = _strdup(tmpnam(NULL));
#else
{
@ -218,7 +220,7 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c
cups_printer = xnew(rdpCupsPrinter);
cups_printer->printer.id = cups_driver->id_sequence++;
cups_printer->printer.name = xstrdup(name);
cups_printer->printer.name = _strdup(name);
/* This is a generic PostScript printer driver developed by MS, so it should be good in most cases */
cups_printer->printer.driver = "MS Publisher Imagesetter";
cups_printer->printer.is_default = is_default;

View File

@ -17,18 +17,22 @@
* limitations under the License.
*/
#include <windows.h>
#include <winspool.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/crt.h>
#include <winpr/windows.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <winspool.h>
#include "config.h"
#include <freerdp/utils/memory.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpdr_types.h"
#include "printer_main.h"
#include "printer_win.h"
@ -179,7 +183,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
win_printer = xnew(rdpWinPrinter);
win_printer->printer.id = win_driver->id_sequence++;
win_printer->printer.name = xstrdup(name);
win_printer->printer.name = _strdup(name);
win_printer->printer.is_default = is_default;
win_printer->printer.CreatePrintJob = printer_win_create_printjob;

View File

@ -18,8 +18,7 @@
# limitations under the License.
set(RDPSND_ALSA_SRCS
rdpsnd_alsa.c
)
rdpsnd_alsa.c)
include_directories(..)
include_directories(${ALSA_INCLUDE_DIRS})
@ -28,9 +27,9 @@ add_library(rdpsnd_alsa ${RDPSND_ALSA_SRCS})
set_target_properties(rdpsnd_alsa PROPERTIES PREFIX "")
if(MONOLITHIC_BUILD)
target_link_libraries(rdpsnd_alsa freerdp)
target_link_libraries(rdpsnd_alsa freerdp winpr)
else()
target_link_libraries(rdpsnd_alsa freerdp-utils)
target_link_libraries(rdpsnd_alsa freerdp-utils winpr-crt)
endif()
target_link_libraries(rdpsnd_alsa ${ALSA_LIBRARIES})

View File

@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <alsa/asoundlib.h>
#include <freerdp/types.h>
@ -434,12 +436,12 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
if (data && strcmp((char*) data->data[0], "alsa") == 0)
{
alsa->device_name = xstrdup((char*) data->data[1]);
alsa->device_name = _strdup((char*) data->data[1]);
}
if (alsa->device_name == NULL)
{
alsa->device_name = xstrdup("default");
alsa->device_name = _strdup("default");
}
alsa->out_handle = 0;

View File

@ -25,7 +25,10 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <pulse/pulseaudio.h>
#include <freerdp/types.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/dsp.h>
@ -541,7 +544,7 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
if (data && strcmp((char*)data->data[0], "pulse") == 0)
{
if(data->data[1] && strlen((char*)data->data[1]) > 0)
pulse->device_name = xstrdup((char*)data->data[1]);
pulse->device_name = _strdup((char*)data->data[1]);
else
pulse->device_name = NULL;
}

View File

@ -59,6 +59,7 @@
#include <freerdp/client/channels.h>
#include <freerdp/rail.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include "xf_gdi.h"
@ -310,7 +311,7 @@ void xf_create_window(xfInfo* xfi)
if (xfi->instance->settings->window_title != NULL)
{
win_title = xstrdup(xfi->instance->settings->window_title);
win_title = _strdup(xfi->instance->settings->window_title);
}
else if (xfi->instance->settings->port == 3389)
{

View File

@ -23,11 +23,11 @@
#include <stddef.h>
#include <ctype.h>
#include <wchar.h>
#include <freerdp/api.h>
FREERDP_API void* xzalloc(size_t size);
FREERDP_API char* xstrdup(const char* str);
FREERDP_API char* xstrtoup(const char* str);
FREERDP_API wchar_t* xwcsdup(const wchar_t* wstr);

View File

@ -104,12 +104,10 @@ if(MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS winpr)
else()
set(${MODULE_PREFIX}_LIBS
winpr-registry
winpr-utils
winpr-sspi)
if(NOT WIN32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-registry)
endif()
winpr-sspi
winpr-crt)
endif()
if(WIN32)

View File

@ -27,6 +27,8 @@
#include "connection.h"
#include "transport.h"
#include <winpr/crt.h>
#include <freerdp/errorcodes.h>
/**
@ -165,30 +167,30 @@ boolean rdp_client_redirect(rdpRdp* rdp)
if (redirection->flags & LB_TARGET_NET_ADDRESS)
{
free(settings->hostname);
settings->hostname = xstrdup(redirection->targetNetAddress.ascii);
settings->hostname = _strdup(redirection->targetNetAddress.ascii);
}
else if (redirection->flags & LB_TARGET_FQDN)
{
free(settings->hostname);
settings->hostname = xstrdup(redirection->targetFQDN.ascii);
settings->hostname = _strdup(redirection->targetFQDN.ascii);
}
else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
{
free(settings->hostname);
settings->hostname = xstrdup(redirection->targetNetBiosName.ascii);
settings->hostname = _strdup(redirection->targetNetBiosName.ascii);
}
}
if (redirection->flags & LB_USERNAME)
{
free(settings->username);
settings->username = xstrdup(redirection->username.ascii);
settings->username = _strdup(redirection->username.ascii);
}
if (redirection->flags & LB_DOMAIN)
{
free(settings->domain);
settings->domain = xstrdup(redirection->domain.ascii);
settings->domain = _strdup(redirection->domain.ascii);
}
if (redirection->flags & LB_PASSWORD)

View File

@ -44,7 +44,7 @@ void http_context_set_method(HttpContext* http_context, char* method)
if (http_context->Method)
free(http_context->Method);
http_context->Method = xstrdup(method);
http_context->Method = _strdup(method);
}
void http_context_set_uri(HttpContext* http_context, char* uri)
@ -52,7 +52,7 @@ void http_context_set_uri(HttpContext* http_context, char* uri)
if (http_context->URI)
free(http_context->URI);
http_context->URI = xstrdup(uri);
http_context->URI = _strdup(uri);
}
void http_context_set_user_agent(HttpContext* http_context, char* user_agent)
@ -60,7 +60,7 @@ void http_context_set_user_agent(HttpContext* http_context, char* user_agent)
if (http_context->UserAgent)
free(http_context->UserAgent);
http_context->UserAgent = xstrdup(user_agent);
http_context->UserAgent = _strdup(user_agent);
}
void http_context_set_host(HttpContext* http_context, char* host)
@ -68,7 +68,7 @@ void http_context_set_host(HttpContext* http_context, char* host)
if (http_context->Host)
free(http_context->Host);
http_context->Host = xstrdup(host);
http_context->Host = _strdup(host);
}
void http_context_set_accept(HttpContext* http_context, char* accept)
@ -76,7 +76,7 @@ void http_context_set_accept(HttpContext* http_context, char* accept)
if (http_context->Accept)
free(http_context->Accept);
http_context->Accept = xstrdup(accept);
http_context->Accept = _strdup(accept);
}
void http_context_set_cache_control(HttpContext* http_context, char* cache_control)
@ -84,7 +84,7 @@ void http_context_set_cache_control(HttpContext* http_context, char* cache_contr
if (http_context->CacheControl)
free(http_context->CacheControl);
http_context->CacheControl = xstrdup(cache_control);
http_context->CacheControl = _strdup(cache_control);
}
void http_context_set_connection(HttpContext* http_context, char* connection)
@ -92,7 +92,7 @@ void http_context_set_connection(HttpContext* http_context, char* connection)
if (http_context->Connection)
free(http_context->Connection);
http_context->Connection = xstrdup(connection);
http_context->Connection = _strdup(connection);
}
void http_context_set_pragma(HttpContext* http_context, char* pragma)
@ -100,7 +100,7 @@ void http_context_set_pragma(HttpContext* http_context, char* pragma)
if (http_context->Pragma)
free(http_context->Pragma);
http_context->Pragma = xstrdup(pragma);
http_context->Pragma = _strdup(pragma);
}
void http_context_free(HttpContext* http_context)
@ -122,7 +122,7 @@ void http_request_set_method(HttpRequest* http_request, char* method)
if (http_request->Method)
free(http_request->Method);
http_request->Method = xstrdup(method);
http_request->Method = _strdup(method);
}
void http_request_set_uri(HttpRequest* http_request, char* uri)
@ -130,7 +130,7 @@ void http_request_set_uri(HttpRequest* http_request, char* uri)
if (http_request->URI)
free(http_request->URI);
http_request->URI = xstrdup(uri);
http_request->URI = _strdup(uri);
}
void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme)
@ -138,7 +138,7 @@ void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme)
if (http_request->AuthScheme)
free(http_request->AuthScheme);
http_request->AuthScheme = xstrdup(auth_scheme);
http_request->AuthScheme = _strdup(auth_scheme);
}
void http_request_set_auth_param(HttpRequest* http_request, char* auth_param)
@ -146,7 +146,7 @@ void http_request_set_auth_param(HttpRequest* http_request, char* auth_param)
if (http_request->AuthParam)
free(http_request->AuthParam);
http_request->AuthParam = xstrdup(auth_param);
http_request->AuthParam = _strdup(auth_param);
}
#ifndef _WIN32
@ -310,7 +310,7 @@ void http_response_parse_header_status_line(HttpResponse* http_response, char* s
*separator = '\0';
http_response->StatusCode = atoi(status_code);
http_response->ReasonPhrase = xstrdup(reason_phrase);
http_response->ReasonPhrase = _strdup(reason_phrase);
*separator = ' ';
}
@ -324,15 +324,15 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c
{
char* separator;
http_response->Authorization = xstrdup(value);
http_response->Authorization = _strdup(value);
separator = strchr(value, ' ');
if (separator != NULL)
{
*separator = '\0';
http_response->AuthScheme = xstrdup(value);
http_response->AuthParam = xstrdup(separator + 1);
http_response->AuthScheme = _strdup(value);
http_response->AuthParam = _strdup(separator + 1);
*separator = ' ';
}
}
@ -355,8 +355,8 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c
/* WWW-Authenticate: NTLM base64token */
*separator = '\0';
http_response->AuthScheme = xstrdup(value);
http_response->AuthParam = xstrdup(separator + 1);
http_response->AuthScheme = _strdup(value);
http_response->AuthParam = _strdup(separator + 1);
*separator = ' ';
return;
@ -473,7 +473,7 @@ HttpResponse* http_response_recv(rdpTls* tls)
while (line != NULL)
{
http_response->lines[count] = xstrdup(line);
http_response->lines[count] = _strdup(line);
line = strtok(NULL, "\r\n");
count++;
}
@ -482,7 +482,7 @@ HttpResponse* http_response_recv(rdpTls* tls)
if (http_response->ContentLength > 0)
{
http_response->Content = xstrdup(content);
http_response->Content = _strdup(content);
}
break;

View File

@ -30,11 +30,12 @@
#include <unistd.h>
#endif
#include <winpr/crt.h>
#include <winpr/registry.h>
#include <freerdp/settings.h>
#include <freerdp/utils/file.h>
#include <winpr/registry.h>
static const char client_dll[] = "C:\\Windows\\System32\\mstscax.dll";
void settings_client_load_hkey_local_machine(rdpSettings* settings)
@ -258,7 +259,7 @@ rdpSettings* settings_new(void* instance)
settings->draw_nine_grid_cache_size = 2560;
settings->draw_nine_grid_cache_entries = 256;
settings->client_dir = xstrdup(client_dll);
settings->client_dir = _strdup(client_dll);
settings->num_icon_caches = 3;
settings->num_icon_cache_entries = 12;

View File

@ -29,6 +29,8 @@
#include <errno.h>
#include <fcntl.h>
#include <winpr/crt.h>
#ifndef _WIN32
#include <netdb.h>
#include <unistd.h>
@ -79,7 +81,7 @@ void tcp_get_ip_address(rdpTcp * tcp)
tcp->ip_address[sizeof(tcp->ip_address) - 1] = 0;
tcp->settings->ipv6 = 0;
tcp->settings->ip_address = xstrdup(tcp->ip_address);
tcp->settings->ip_address = _strdup(tcp->ip_address);
}
void tcp_get_mac_address(rdpTcp * tcp)

View File

@ -59,8 +59,10 @@ else()
endif()
if(MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

View File

@ -26,6 +26,8 @@
#include <stdio.h>
#include <string.h>
#include <winpr/crt.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
@ -217,8 +219,8 @@ rdpCertificateData* certificate_data_new(char* hostname, char* fingerprint)
if (certdata != NULL)
{
certdata->hostname = xstrdup(hostname);
certdata->fingerprint = xstrdup(fingerprint);
certdata->hostname = _strdup(hostname);
certdata->fingerprint = _strdup(fingerprint);
}
return certdata;

View File

@ -81,8 +81,10 @@ endif()
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

View File

@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include "liblocale.h"
#include <freerdp/types.h>
@ -492,7 +494,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_LAYOUT_TABLE[i].code;
layouts[num].name = xstrdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name);
layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name);
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0)
@ -503,7 +505,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code;
layouts[num].name = xstrdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name);
layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name);
}
}
if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0)
@ -514,7 +516,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types)
for (i = 0; i < length; i++, num++)
{
layouts[num].code = RDP_KEYBOARD_IME_TABLE[i].code;
layouts[num].name = xstrdup(RDP_KEYBOARD_IME_TABLE[i].name);
layouts[num].name = _strdup(RDP_KEYBOARD_IME_TABLE[i].name);
}
}

View File

@ -25,7 +25,10 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include "liblocale.h"
#include <freerdp/utils/memory.h>
#include <freerdp/locale/locale.h>
#include <freerdp/locale/keyboard.h>
@ -103,8 +106,8 @@ uint32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var
if (keyboardLayoutId > 0)
{
*xkb_layout = xstrdup(layout);
*xkb_variant = xstrdup(variant);
*xkb_layout = _strdup(layout);
*xkb_variant = _strdup(variant);
return keyboardLayoutId;
}
@ -149,8 +152,8 @@ uint32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var
if (keyboardLayoutId > 0)
{
*xkb_layout = xstrdup(layout);
*xkb_variant = xstrdup(variant);
*xkb_layout = _strdup(layout);
*xkb_variant = _strdup(variant);
return keyboardLayoutId;
}

View File

@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include "liblocale.h"
#include <freerdp/utils/time.h>
@ -1502,7 +1504,7 @@ char* freerdp_get_unix_timezone_identifier()
if (tz_env != NULL)
{
tzid = xstrdup(tz_env);
tzid = _strdup(tz_env);
return tzid;
}
@ -1576,7 +1578,7 @@ boolean freerdp_match_unix_timezone_identifier_with_list(const char* tzid, const
char* p;
char* list_copy;
list_copy = xstrdup(list);
list_copy = _strdup(list);
p = strtok(list_copy, " ");

View File

@ -76,12 +76,7 @@ if(MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
if(NOT WIN32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt)
endif()
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-synch)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt winpr-synch)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#ifdef _WIN32
#include <io.h>
#define isatty _isatty
@ -51,7 +53,7 @@ void freerdp_parse_hostname(rdpSettings* settings, char* hostname)
&& (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
{
/* Either "[...]" or "[...]:..." with at most one : after the brackets */
settings->hostname = xstrdup(hostname + 1);
settings->hostname = _strdup(hostname + 1);
if ((p = strchr((char*)settings->hostname, ']')))
{
@ -64,7 +66,7 @@ void freerdp_parse_hostname(rdpSettings* settings, char* hostname)
else
{
/* Port number is cut off and used if exactly one : in the string */
settings->hostname = xstrdup(hostname);
settings->hostname = _strdup(hostname);
if ((p = strchr((char*)settings->hostname, ':')) && !strchr(p + 1, ':'))
{
@ -185,7 +187,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing username\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->username = xstrdup(argv[index]);
settings->username = _strdup(argv[index]);
}
else if (strcmp("-p", argv[index]) == 0)
{
@ -195,7 +197,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing password\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->password = xstrdup(argv[index]);
settings->password = _strdup(argv[index]);
settings->autologon = 1;
/*
@ -213,7 +215,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing domain\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->domain = xstrdup(argv[index]);
settings->domain = _strdup(argv[index]);
}
else if (strcmp("-s", argv[index]) == 0)
{
@ -223,7 +225,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing shell\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->shell = xstrdup(argv[index]);
settings->shell = _strdup(argv[index]);
}
else if (strcmp("-c", argv[index]) == 0)
{
@ -233,7 +235,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing directory\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->directory = xstrdup(argv[index]);
settings->directory = _strdup(argv[index]);
}
else if (strcmp("-g", argv[index]) == 0)
{
@ -289,7 +291,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->window_title = xstrdup(argv[index]);
settings->window_title = _strdup(argv[index]);
}
else if (strcmp("-t", argv[index]) == 0)
{
@ -384,7 +386,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->certificate_name = xstrdup(argv[index]);
settings->certificate_name = _strdup(argv[index]);
}
else if (strcmp("--no-fastpath", argv[index]) == 0)
{
@ -520,7 +522,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing file name\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->dump_rfx_file = xstrdup(argv[index]);
settings->dump_rfx_file = _strdup(argv[index]);
settings->dump_rfx = true;
settings->rfx_codec_only = true;
}
@ -532,7 +534,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing file name\n");
return FREERDP_ARGS_PARSE_FAILURE;
}
settings->play_rfx_file = xstrdup(argv[index]);
settings->play_rfx_file = _strdup(argv[index]);
settings->play_rfx = true;
}
else if (strcmp("--fonts", argv[index]) == 0)
@ -679,21 +681,21 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing TSG username\n");
return -1;
}
settings->tsg_username = xstrdup(argv[index]);
settings->tsg_username = _strdup(argv[index]);
index++;
if (index == argc)
{
printf("missing TSG password\n");
return -1;
}
settings->tsg_password = xstrdup(argv[index]);
settings->tsg_password = _strdup(argv[index]);
index++;
if (index == argc)
{
printf("missing TSG server\n");
return -1;
}
settings->tsg_hostname = xstrdup(argv[index]);
settings->tsg_hostname = _strdup(argv[index]);
}
else if (strcmp("--plugin", argv[index]) == 0)
{
@ -809,7 +811,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
return -1;
}
settings->send_preconnection_pdu = true;
settings->preconnection_blob = xstrdup(argv[index]);
settings->preconnection_blob = _strdup(argv[index]);
}
else if (strcmp("--version", argv[index]) == 0)
{
@ -874,7 +876,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
input[0] = '\0';
printf("username: ");
if (scanf("%511s", input) > 0) {
settings->username = xstrdup(input);
settings->username = _strdup(input);
}
}
/* password */
@ -899,7 +901,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
/* Try to catch the cases where the string is NULL-ish right
at the get go */
if (input[0] != '\0' && !(input[0] == '.' && input[1] == '\0')) {
settings->domain = xstrdup(input);
settings->domain = _strdup(input);
}
}
}

View File

@ -26,6 +26,8 @@
#include <string.h>
#include <sys/stat.h>
#include <winpr/crt.h>
#include <freerdp/types.h>
#include <freerdp/settings.h>
#include <freerdp/utils/memory.h>
@ -87,7 +89,7 @@ char* freerdp_get_home_path(rdpSettings* settings)
if (settings->home_path == NULL)
settings->home_path = getenv(HOME_ENV_VARIABLE);
if (settings->home_path == NULL)
settings->home_path = xstrdup("/");
settings->home_path = _strdup("/");
return settings->home_path;
}
@ -155,7 +157,7 @@ char* freerdp_append_shared_library_suffix(char* file_path)
}
else
{
path = xstrdup(file_path);
path = _strdup(file_path);
}
}
else
@ -179,7 +181,7 @@ char* freerdp_get_parent_path(char* base_path, int depth)
return NULL;
if (depth <= 0)
return xstrdup(base_path);
return _strdup(base_path);
base_length = strlen(base_path);

View File

@ -24,7 +24,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
#include <freerdp/utils/file.h>
#include <freerdp/utils/print.h>
#include <freerdp/utils/memory.h>
@ -129,7 +132,7 @@ void* freerdp_load_plugin(const char* name, const char* entry_name)
else
{
/* explicit path given, use it instead of default path */
path = xstrdup(suffixed_name);
path = _strdup(suffixed_name);
}
entry = freerdp_load_library_symbol(path, entry_name);

View File

@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <freerdp/utils/memory.h>
/**
@ -54,37 +56,6 @@ void* xzalloc(size_t size)
return mem;
}
/**
* Duplicate a string in memory.
* This function is used to secure the strdup function.
* It will allocate a new memory buffer and copy the string content in it.
* If allocation fails, it will log an error.
*
* @param str - pointer to the character string to copy. If str is NULL, nothing is done.
*
* @return a pointer to a newly allocated character string containing the same bytes as str.
* NULL if an allocation error occurred, or if the str parameter was NULL.
*/
char* xstrdup(const char* str)
{
char* mem;
if (str == NULL)
return NULL;
#ifdef _WIN32
mem = _strdup(str);
#else
mem = strdup(str);
#endif
if (mem == NULL)
perror("strdup");
return mem;
}
/**
* Duplicate a wide string in memory.
* This function is used to secure a call to wcsdup.
@ -136,15 +107,19 @@ char* xstrtoup(const char* str)
char* out;
char* p;
int c;
out = xstrdup(str);
if(out != NULL)
out = _strdup(str);
if (out != NULL)
{
p = out;
while(*p != '\0')
while (*p != '\0')
{
c = toupper((unsigned char)*p);
*p++ = (char)c;
*p++ = (char) c;
}
}
return out;
}

View File

@ -30,10 +30,12 @@ add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
if(MONOLITHIC_BUILD)
target_link_libraries(${MODULE_NAME}
winpr
freerdp
freerdp-channels-server)
else()
target_link_libraries(${MODULE_NAME}
winpr-crt
freerdp-core
freerdp-utils
freerdp-codec

View File

@ -30,6 +30,8 @@
#include <signal.h>
#include <sys/time.h>
#include <winpr/crt.h>
#include <freerdp/constants.h>
#include <freerdp/utils/sleep.h>
#include <freerdp/utils/memory.h>
@ -650,8 +652,8 @@ static void* test_peer_mainloop(void* arg)
test_peer_init(client);
/* Initialize the real server settings here */
client->settings->cert_file = xstrdup("server.crt");
client->settings->privatekey_file = xstrdup("server.key");
client->settings->cert_file = _strdup("server.crt");
client->settings->privatekey_file = _strdup("server.key");
client->settings->nla_security = false;
client->settings->rfx_codec = true;
client->settings->suppress_output = true;