Merge "QEMU update with VENOM (CVE-2015-3456) patch" into 5.0.2
[packages/centos6/qemu.git] / 0220-lm4549-Fix-buffer-overflow.patch
1 From 00338325c4a2c5b0010462b21a4373cbb4341c9d Mon Sep 17 00:00:00 2001
2 From: Stefan Weil <sw@weilnetz.de>
3 Date: Sat, 1 Sep 2012 12:43:41 +0200
4 Subject: [PATCH] lm4549: Fix buffer overflow
5
6 Report from smatch:
7 lm4549.c:234 lm4549_write_samples(14) error:
8  buffer overflow 's->buffer' 1024 <= 1024
9
10 There must be enough space to add two entries starting with index
11 s->buffer_level, therefore the old check was wrong.
12
13 [Peter Maydell <peter.maydell@linaro.org> clarifies the nature of the
14 analyser warning:
15
16 I don't object to making the change to placate the analyser,
17 but I don't think this is actually a buffer overrun. We always
18 add and remove samples from the buffer two at a time, so it's
19 not possible to get here with s->buffer_level == BUFFER_SIZE-1
20 (which is the only case where the old and new conditions
21 give different answers).]
22
23 Signed-off-by: Stefan Weil <sw@weilnetz.de>
24 Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
25 (cherry picked from commit 8139626643cbe8dc07bd9acc88057effeedf8064)
26
27 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
28 ---
29  hw/lm4549.c | 2 +-
30  1 file changed, 1 insertion(+), 1 deletion(-)
31
32 diff --git a/hw/lm4549.c b/hw/lm4549.c
33 index 80b3ec4..e0137d5 100644
34 --- a/hw/lm4549.c
35 +++ b/hw/lm4549.c
36 @@ -224,7 +224,7 @@ uint32_t lm4549_write_samples(lm4549_state *s, uint32_t left, uint32_t right)
37         This model supports 16-bit playback.
38      */
39  
40 -    if (s->buffer_level >= LM4549_BUFFER_SIZE) {
41 +    if (s->buffer_level > LM4549_BUFFER_SIZE - 2) {
42          DPRINTF("write_sample Buffer full\n");
43          return 0;
44      }
45 -- 
46 1.7.12.1
47