author | Alan Coopersmith <Alan.Coopersmith@Oracle.COM> |
Wed, 15 May 2013 13:44:02 -0700 | |
changeset 1345 | d5dacbb8de2b |
permissions | -rw-r--r-- |
1345
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
1 |
From e480abd0af181242022a85bff2d4d5e73385255e Mon Sep 17 00:00:00 2001 |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
2 |
From: Alan Coopersmith <[email protected]> |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
3 |
Date: Wed, 1 May 2013 17:59:31 -0700 |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
4 |
Subject: [PATCH:libxcb] integer overflow in read_packet() [CVE-2013-2064] |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
5 |
|
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
6 |
Ensure that when calculating the size of the incoming response from the |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
7 |
Xserver, we don't overflow the integer used in the calculations when we |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
8 |
multiply the int32_t length by 4 and add it to the default response size. |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
9 |
|
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
10 |
Signed-off-by: Alan Coopersmith <[email protected]> |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
11 |
--- |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
12 |
src/xcb_in.c | 13 +++++++++---- |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
13 |
1 file changed, 9 insertions(+), 4 deletions(-) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
14 |
|
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
15 |
diff --git a/src/xcb_in.c b/src/xcb_in.c |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
16 |
index b810783..8a7af92 100644 |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
17 |
--- a/src/xcb_in.c |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
18 |
+++ b/src/xcb_in.c |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
19 |
@@ -93,8 +93,9 @@ static void remove_finished_readers(reader_list **prev_reader, uint64_t complete |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
20 |
static int read_packet(xcb_connection_t *c) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
21 |
{ |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
22 |
xcb_generic_reply_t genrep; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
23 |
- int length = 32; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
24 |
- int eventlength = 0; /* length after first 32 bytes for GenericEvents */ |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
25 |
+ uint64_t length = 32; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
26 |
+ uint64_t eventlength = 0; /* length after first 32 bytes for GenericEvents */ |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
27 |
+ uint64_t bufsize; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
28 |
void *buf; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
29 |
pending_reply *pend = 0; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
30 |
struct event_list *event; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
31 |
@@ -169,8 +170,12 @@ static int read_packet(xcb_connection_t *c) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
32 |
if ((genrep.response_type & 0x7f) == XCB_XGE_EVENT) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
33 |
eventlength = genrep.length * 4; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
34 |
|
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
35 |
- buf = malloc(length + eventlength + |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
36 |
- (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t))); |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
37 |
+ bufsize = length + eventlength + |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
38 |
+ (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t)); |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
39 |
+ if (bufsize < INT32_MAX) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
40 |
+ buf = malloc((size_t) bufsize); |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
41 |
+ else |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
42 |
+ buf = NULL; |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
43 |
if(!buf) |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
44 |
{ |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
45 |
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT); |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
46 |
-- |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
47 |
1.7.9.2 |
d5dacbb8de2b
16673783 problem in X11/LIBRARIES
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff
changeset
|
48 |