summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-01-06 23:30:14 -0800
committerJulien Cristau <jcristau@debian.org>2014-12-09 17:50:12 +0100
commitcbfdb284c943c202c1fd47e560bd980a74dd662b (patch)
tree11e099af0176b3efec9c48d9557d8db1197ce0ac
parentb022d4ef9d89c806024bd0cd367da1b249cc2b2d (diff)
dix: integer overflow in GetHosts() [CVE-2014-8092 2/4]
GetHosts() iterates over all the hosts it has in memory, and copies them to a buffer. The buffer length is calculated by iterating over all the hosts and adding up all of their combined length. There is a potential integer overflow, if there are lots and lots of hosts (with a combined length of > ~4 gig). This should be possible by repeatedly calling ProcChangeHosts() on 64bit machines with enough memory. This patch caps the list at 1mb, because multi-megabyte hostname lists for X access control are insane. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit bc8e20430b6f6378daf6ce4329029248a88af08b) Signed-off-by: Julien Cristau <jcristau@debian.org>
-rw-r--r--os/access.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/os/access.c b/os/access.c
index e8c0781f2..e5a067220 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1323,6 +1323,10 @@ GetHosts(void **data, int *pnHosts, int *pLen, BOOL * pEnabled)
for (host = validhosts; host; host = host->next) {
nHosts++;
n += pad_to_int32(host->len) + sizeof(xHostEntry);
+ /* Could check for INT_MAX, but in reality having more than 1mb of
+ hostnames in the access list is ridiculous */
+ if (n >= 1048576)
+ break;
}
if (n) {
*data = ptr = malloc(n);
@@ -1331,6 +1335,8 @@ GetHosts(void **data, int *pnHosts, int *pLen, BOOL * pEnabled)
}
for (host = validhosts; host; host = host->next) {
len = host->len;
+ if ((ptr + sizeof(xHostEntry) + len) > (data + n))
+ break;
((xHostEntry *) ptr)->family = host->family;
((xHostEntry *) ptr)->length = len;
ptr += sizeof(xHostEntry);