]> git.ipfire.org Git - thirdparty/qemu.git/commit
lm4549: Fix buffer overflow
authorStefan Weil <sw@weilnetz.de>
Sat, 1 Sep 2012 10:43:41 +0000 (12:43 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Fri, 12 Oct 2012 02:44:20 +0000 (21:44 -0500)
commit2b9a5aca51fba0d02af3ed5768adb1f448327d2f
tree7cf8e96a3ed0da0d0423ef7c58c7ebaacb979540
parent96d90d32ac4f3f2d39e0df881e0a9b12007a6d0d
lm4549: Fix buffer overflow

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.

[Peter Maydell <peter.maydell@linaro.org> clarifies the nature of the
analyser warning:

I don't object to making the change to placate the analyser,
but I don't think this is actually a buffer overrun. We always
add and remove samples from the buffer two at a time, so it's
not possible to get here with s->buffer_level == BUFFER_SIZE-1
(which is the only case where the old and new conditions
give different answers).]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
(cherry picked from commit 8139626643cbe8dc07bd9acc88057effeedf8064)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/lm4549.c