[PATCH xserver 3/4] os: Use strtok instead of xstrtokenize in ComputeLocalClient

walter harms wharms at bfs.de
Mon Jun 6 15:16:50 UTC 2016



Am 05.06.2016 05:27, schrieb Keith Packard:
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> Fixes leaking the memory pointed to by the members of the array returned
> by xstrtokenize.
> 
> Reviewed-by: Adam Jackson <ajax at redhat.com>
> ---
>  os/access.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/os/access.c b/os/access.c
> index 58f95a9..8828e08 100644
> --- a/os/access.c
> +++ b/os/access.c
> @@ -1131,19 +1131,20 @@ ComputeLocalClient(ClientPtr client)
>       * is forwarded from another host via SSH
>       */
>      if (cmdname) {
> -        char **cmd;
> +        char *cmd = strdup(cmdname);
>          Bool ret;
>  
>          /* Cut off any colon and whatever comes after it, see
>           * https://lists.freedesktop.org/archives/xorg-devel/2015-December/048164.html
>           */
> -        cmd = xstrtokenize(cmdname, ":");
> +        cmd = strtok(cmd, ":");
>  
>  #if !defined(WIN32) || defined(__CYGWIN__)
> -        cmd[0] = basename(cmd[0]);
> +        ret = strcmp(basename(cmd), "ssh") != 0;
> +#else
> +        ret = strcmp(cmd, "ssh") != 0;
>  #endif


i am wondering,
 would basename(cmd) hurt the unix side ?
 if not that basename() could be moved to strdup() above
and the #if removed.

just my 2 cents

re,
 wh
>  
> -        ret = strcmp(cmd[0], "ssh") != 0;
>          free(cmd);
>  
>          return ret;


More information about the xorg-devel mailing list