On 07/ 9/11 01:05 PM, Kees Cook wrote:
> In the ServerInterpreted case, XAddHost and XRemoveHost are capable of
> failing when they lack request buffer memory. Notice this situation,
> and report correctly.
> 
> Signed-off-by: Kees Cook <[email protected]>
> ---
>  xhost.c |   11 +++++++----
>  1 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/xhost.c b/xhost.c
> index c7faeff..49d4690 100644
> --- a/xhost.c
> +++ b/xhost.c
> @@ -450,7 +450,7 @@ change_host(Display *dpy, char *name, Bool add)
>  
>      if (family == FamilyServerInterpreted) {
>       XServerInterpretedAddress siaddr;
> -     int namelen;
> +     int namelen, rc;
>  
>       cp = strchr(name, ':');
>       if (cp == NULL || cp == name) {
> @@ -472,11 +472,14 @@ change_host(Display *dpy, char *name, Bool add)
>       siaddr.value = siaddr.type + siaddr.typelength + 1;
>       siaddr.valuelength = namelen - (siaddr.typelength + 1);
>       if (add)
> -         XAddHost(dpy, &ha);
> +         rc = XAddHost(dpy, &ha);
>       else
> -         XRemoveHost(dpy, &ha);
> +         rc = XRemoveHost(dpy, &ha);
>       free(siaddr.type);
> -     printf( "%s %s\n", name, add ? add_msg : remove_msg);
> +     printf( "%s %s%s\n", name, rc == 1 ? "" : "failed when ",
> +             add ? add_msg : remove_msg);
> +     if (rc != 1)
> +         return 0;
>       return 1;
>      }
>  

Reviewed-by: Alan Coopersmith <[email protected]>

-- 
        -Alan Coopersmith-        [email protected]
         Oracle Solaris Platform Engineering: X Window System

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to