client/test: fix string handling
This commit is contained in:
parent
8761b1d9a8
commit
cb7535bbb5
@ -34,7 +34,7 @@
|
||||
} while(0)
|
||||
|
||||
#define STRING_COPY(_str) do { \
|
||||
settings->_str = xmalloc(strlen(argv[*i])); \
|
||||
settings->_str = xmalloc(strlen(argv[*i]) + 1); \
|
||||
memcpy(settings->_str, argv[*i], strlen(argv[*i])); \
|
||||
settings->_str[strlen(argv[*i])] = '\0'; \
|
||||
} while(0)
|
||||
@ -145,7 +145,7 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in
|
||||
&& (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
|
||||
{
|
||||
/* Either "[...]" or "[...]:..." with at most one : after the brackets */
|
||||
settings->hostname = (char*) xmalloc(strlen(argv[*i] + 1));
|
||||
settings->hostname = (char*) xmalloc(strlen(argv[*i]) + 1);
|
||||
strncpy(settings->hostname, argv[*i] + 1, strlen(argv[*i] + 1));
|
||||
|
||||
if ((p = strchr((const char*)settings->hostname, ']')))
|
||||
@ -158,10 +158,11 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in
|
||||
else
|
||||
{
|
||||
/* Port number is cut off and used if exactly one : in the string */
|
||||
settings->hostname = (char*) xmalloc(strlen(argv[*i]));
|
||||
settings->hostname = (char*) xmalloc(strlen(argv[*i]) + 1);
|
||||
strncpy(settings->hostname, argv[*i], strlen(argv[*i]));
|
||||
settings->hostname[strlen(argv[*i])] = '\0';
|
||||
|
||||
if ((p = strchr((const char*)settings->hostname, ':')) && !strchr(p + 1, ':'))
|
||||
if ((p = strchr(settings->hostname, ':')) && !strchr(p + 1, ':'))
|
||||
{
|
||||
*p = 0;
|
||||
settings->port = (uint16) atoi(p + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user