Skip to content
  • Volker Rümelin's avatar
    b6d93282
    audio: prevent an integer overflow in resampling code · b6d93282
    Volker Rümelin authored
    
    
    There are corner cases where rate->opos can overflow. For
    example, if QEMU is started with -audiodev pa,id=audio0,
    out.frequency=11025 -device ich9-intel-hda -device hda-duplex,
    audiodev=audio0 and the guest plays audio with a sampling
    frequency of 44100Hz, rate->opos will overflow after 27.05h
    and the audio stream will be silent for a long time.
    
    To prevent a rate->opos and also a rate->ipos overflow, both
    are wrapped around after a short time. The wrap around point
    rate->ipos >= 0x10001 is an arbitrarily selected value and can
    be any small value, 0 and 1 included.
    
    The comment that an ipos overflow will result in an infinite
    loop has been removed, because in this case the resampling code
    only generates no more output samples and the audio stream stalls.
    However, there is no infinite loop.
    
    Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
    Message-Id: <20220923183640.8314-12-vr_qemu@t-online.de>
    Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
    b6d93282
    audio: prevent an integer overflow in resampling code
    Volker Rümelin authored
    
    
    There are corner cases where rate->opos can overflow. For
    example, if QEMU is started with -audiodev pa,id=audio0,
    out.frequency=11025 -device ich9-intel-hda -device hda-duplex,
    audiodev=audio0 and the guest plays audio with a sampling
    frequency of 44100Hz, rate->opos will overflow after 27.05h
    and the audio stream will be silent for a long time.
    
    To prevent a rate->opos and also a rate->ipos overflow, both
    are wrapped around after a short time. The wrap around point
    rate->ipos >= 0x10001 is an arbitrarily selected value and can
    be any small value, 0 and 1 included.
    
    The comment that an ipos overflow will result in an infinite
    loop has been removed, because in this case the resampling code
    only generates no more output samples and the audio stream stalls.
    However, there is no infinite loop.
    
    Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
    Message-Id: <20220923183640.8314-12-vr_qemu@t-online.de>
    Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Loading