diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2020-01-02 23:16:13 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-01-05 21:44:12 +0100 |
commit | ee3afe303fc35b98e5f674efc91fdeb2183dfcb5 (patch) | |
tree | 3a59aa9d5ff1bf6e8a93b92de43cd6eca0a6a1f3 /nx-X11/programs/Xserver | |
parent | 8fa4d842d482a61cfe63cb2ca1459e48214fac34 (diff) | |
download | nx-libs-ee3afe303fc35b98e5f674efc91fdeb2183dfcb5.tar.gz nx-libs-ee3afe303fc35b98e5f674efc91fdeb2183dfcb5.tar.bz2 nx-libs-ee3afe303fc35b98e5f674efc91fdeb2183dfcb5.zip |
Args.c: fix: do not modify options string
This resulted in a garbled option string on reconnect where everything
after the first '=' was lost!
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Args.c | 11 |
1 files changed, 9 insertions, 2 deletions
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 @@ -1489,10 +1489,16 @@ static void nxagentParseOptionString(char *string) 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) |