From ee3afe303fc35b98e5f674efc91fdeb2183dfcb5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 2 Jan 2020 23:16:13 +0100 Subject: Args.c: fix: do not modify options string This resulted in a garbled option string on reconnect where everything after the first '=' was lost! --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index ea3c7ae26..1bfec1798 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1488,11 +1488,17 @@ static void nxagentParseOptionString(char *string) char *value = NULL; char *option = NULL; + /* + * we must not modify string, but strtok will insert \0. So let's + * work with a copy + */ + char *dup = strdup(string); + /* * Remove the port specification. */ - char *delimiter = rindex(string, ':'); + char *delimiter = rindex(dup, ':'); if (delimiter) { @@ -1503,7 +1509,7 @@ static void nxagentParseOptionString(char *string) fprintf(stderr, "Warning: Option file doesn't contain a port specification.\n"); } - while ((option = strtok(option ? NULL : string, ","))) + while ((option = strtok(option ? NULL : dup, ","))) { delimiter = rindex(option, '='); @@ -1519,6 +1525,7 @@ static void nxagentParseOptionString(char *string) nxagentParseSingleOption(option, value); } + SAFE_free(dup); } void nxagentProcessOptions(char * string) -- cgit v1.2.3