Skip to content
  • Stefan Weil's avatar
    lm4549: Fix buffer overflow · 81396266
    Stefan Weil authored
    
    
    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: default avatarStefan Weil <sw@weilnetz.de>
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@gmail.com>
    81396266