VirtualBox

Changeset 99559 in vbox


Ignore:
Timestamp:
Apr 28, 2023 2:30:50 PM (19 months ago)
Author:
vboxsync
Message:

Audio: Improved range checks for audio channels (PDMAUDIO_MAX_CHANNELS).

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioinline.h

    r98103 r99559  
    407407DECLINLINE(void) PDMAudioPropsInit(PPDMAUDIOPCMPROPS pProps, uint8_t cbSample, bool fSigned, uint8_t cChannels, uint32_t uHz)
    408408{
     409    Assert(cChannels <= PDMAUDIO_MAX_CHANNELS);
     410
    409411    pProps->cbFrame     = cbSample * cChannels;
    410412    pProps->cbSampleX   = cbSample;
     
    429431                                     bool fLittleEndian, bool fRaw)
    430432{
     433    Assert(cChannels <= PDMAUDIO_MAX_CHANNELS);
    431434    Assert(!fRaw || cbSample == sizeof(int64_t));
    432435    pProps->cbFrame     = cbSample * cChannels;
     
    503506DECL_FORCE_INLINE(uint8_t) PDMAudioPropsChannels(PCPDMAUDIOPCMPROPS pProps)
    504507{
     508    AssertReturn(pProps->cChannelsX <= PDMAUDIO_MAX_CHANNELS, PDMAUDIO_MAX_CHANNELS);
    505509    return pProps->cChannelsX;
    506510}
  • trunk/src/VBox/Devices/Audio/AudioTest.cpp

    r98103 r99559  
    32763276                                  uBuf.Wave.u.FmtExt.Data.fChannelMask,
    32773277                                  audioTestWaveCountBits(uBuf.Wave.u.FmtExt.Data.fChannelMask), uBuf.Wave.u.Fmt.Data.cChannels);
     3278                else if (uBuf.Wave.u.Fmt.Data.cChannels > PDMAUDIO_MAX_CHANNELS)
     3279                    RTErrInfoSetF(pErrInfo, rc, "More than %u channels are not supported (%u given)",
     3280                                  PDMAUDIO_MAX_CHANNELS, uBuf.Wave.u.Fmt.Data.cChannels);
    32783281                else if (   uBuf.Wave.u.Fmt.Data.uFormatTag == RTRIFFWAVEFMT_TAG_EXTENSIBLE
    32793282                         && RTUuidCompareStr(&uBuf.Wave.u.FmtExt.Data.SubFormat, RTRIFFWAVEFMTEXT_SUBTYPE_PCM) != 0)
     
    32973300                                                          - (unsigned)PDMAUDIOCHANNELID_FIRST_STANDARD;
    32983301                        unsigned                iCh       = 0;
    3299                         for (unsigned idCh = 0; idCh < 32 && iCh < uBuf.Wave.u.Fmt.Data.cChannels; idCh++)
     3302                        for (unsigned idCh = 0; idCh < PDMAUDIO_MAX_CHANNELS && iCh < uBuf.Wave.u.Fmt.Data.cChannels; idCh++)
    33003303                            if (uBuf.Wave.u.FmtExt.Data.fChannelMask & RT_BIT_32(idCh))
    33013304                            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette