diff options
author | Kees Cook <kees.cook@canonical.com> | 2011-07-09 13:05:17 -0700 |
---|---|---|
committer | Julien Cristau <jcristau@debian.org> | 2011-07-19 21:08:56 +0200 |
commit | 24685cf1a3987a72310b0160b102fef615359731 (patch) | |
tree | ca28aff3aca1dd087edd42766d7f027c60ab5c5d | |
parent | 29215ba31a7e173e55e7db73eb4c0040ae82881c (diff) |
xhost: check return value of X{Add,Remove}Host
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 <kees.cook@canonical.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
-rw-r--r-- | xhost.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; } |