Commit | Line | Data |
---|---|---|
1e5b8bee LF |
1 | Fix CVE-2017-6386 (memory leak introduced by fix for CVE-2017-5994). |
2 | ||
3 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5994 | |
4 | ||
5 | Patch copied from upstream source repository: | |
6 | ||
7 | https://cgit.freedesktop.org/virglrenderer/commit/?id=737c3350850ca4dbc5633b3bdb4118176ce59920 | |
8 | ||
9 | From 737c3350850ca4dbc5633b3bdb4118176ce59920 Mon Sep 17 00:00:00 2001 | |
10 | From: Dave Airlie <airlied@redhat.com> | |
11 | Date: Tue, 28 Feb 2017 14:52:09 +1000 | |
12 | Subject: renderer: fix memory leak in vertex elements state create | |
13 | ||
14 | Reported-by: Li Qiang | |
15 | Free the vertex array in error path. | |
16 | This was introduced by this commit: | |
17 | renderer: fix heap overflow in vertex elements state create. | |
18 | ||
19 | I rewrote the code to not require the allocation in the first | |
20 | place if we have an error, seems nicer. | |
21 | ||
22 | Signed-off-by: Dave Airlie <airlied@redhat.com> | |
23 | ||
24 | diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c | |
25 | index 1bca7ad..e5d9f5c 100644 | |
26 | --- a/src/vrend_renderer.c | |
27 | +++ b/src/vrend_renderer.c | |
28 | @@ -1648,18 +1648,19 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx, | |
29 | unsigned num_elements, | |
30 | const struct pipe_vertex_element *elements) | |
31 | { | |
32 | - struct vrend_vertex_element_array *v = CALLOC_STRUCT(vrend_vertex_element_array); | |
33 | + struct vrend_vertex_element_array *v; | |
34 | const struct util_format_description *desc; | |
35 | GLenum type; | |
36 | int i; | |
37 | uint32_t ret_handle; | |
38 | ||
39 | - if (!v) | |
40 | - return ENOMEM; | |
41 | - | |
42 | if (num_elements > PIPE_MAX_ATTRIBS) | |
43 | return EINVAL; | |
44 | ||
45 | + v = CALLOC_STRUCT(vrend_vertex_element_array); | |
46 | + if (!v) | |
47 | + return ENOMEM; | |
48 | + | |
49 | v->count = num_elements; | |
50 | for (i = 0; i < num_elements; i++) { | |
51 | memcpy(&v->elements[i].base, &elements[i], sizeof(struct pipe_vertex_element)); | |
52 | -- | |
53 | cgit v0.10.2 | |
54 |