Received: from eggs.gnu.org ([208.118.235.92]:36546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7lB5-0000jw-Nf for qemu-devel@nongnu.org; Sat, 01 Sep 2012 06:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7lB4-0003OZ-Lr for qemu-devel@nongnu.org; Sat, 01 Sep 2012 06:43:47 -0400 From: Stefan Weil Date: Sat, 1 Sep 2012 12:43:41 +0200 Message-Id: <1346496221-11188-1-git-send-email-sw@weilnetz.de> Subject: [Qemu-devel] [PATCH] lm4549: Fix buffer overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mathieu Sonet Cc: qemu-trivial@nongnu.org, Stefan Weil , qemu-devel@nongnu.org Report from smatch: lm4549.c:234 lm4549_write_samples(14) error: buffer overflow 's->buffer' 1024 <= 1024 There must be enough space to add two entries starting with index s->buffer_level, therefore the old check was wrong. Signed-off-by: Stefan Weil --- hw/lm4549.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/lm4549.c b/hw/lm4549.c index 80b3ec4..e0137d5 100644 --- a/hw/lm4549.c +++ b/hw/lm4549.c @@ -224,7 +224,7 @@ uint32_t lm4549_write_samples(lm4549_state *s, uint32_t left, uint32_t right) This model supports 16-bit playback. */ - if (s->buffer_level >= LM4549_BUFFER_SIZE) { + if (s->buffer_level > LM4549_BUFFER_SIZE - 2) { DPRINTF("write_sample Buffer full\n"); return 0; } -- 1.7.10