VirtualBox

Changeset 103066 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 25, 2024 3:03:18 PM (10 months ago)
Author:
vboxsync
Message:

iprt: Prevent array-index-out-of-bounds UBSAN warnings on Linux, bugref:10585.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r101362 r103066  
    549549        uint16_t const iGroup = RT_HI_U16(fFlagsAndGroup);
    550550        if (   iGroup != UINT16_MAX
    551             && (   (pLoggerInt->afGroups[iGroup < pLoggerInt->cGroups ? iGroup : 0] & (fFlags | RTLOGGRPFLAGS_ENABLED))
     551            && (   (*(pLoggerInt->afGroups + (iGroup < pLoggerInt->cGroups ? iGroup : 0)) & (fFlags | RTLOGGRPFLAGS_ENABLED))
    552552                != (fFlags | RTLOGGRPFLAGS_ENABLED)))
    553553            pLoggerInt = NULL;
     
    15561556    iGroup = pLoggerInt->cGroups;
    15571557    while (iGroup-- > 0)
    1558         pLoggerInt->afGroups[iGroup] = 0;
     1558        *(pLoggerInt->afGroups + iGroup) = 0;
    15591559
    15601560    /*
     
    17891789            {
    17901790                if (fEnabled)
    1791                     pLoggerInt->afGroups[i] |= fFlags;
     1791                    *(pLoggerInt->afGroups + i) |= fFlags;
    17921792                else
    1793                     pLoggerInt->afGroups[i] &= ~fFlags;
     1793                    *(pLoggerInt->afGroups + i) &= ~fFlags;
    17941794            }
    17951795        }
     
    41594159        return VINF_LOG_DISABLED;
    41604160    if (    iGroup != ~0U
    4161         &&  (pLoggerInt->afGroups[iGroup] & (fFlags | RTLOGGRPFLAGS_ENABLED)) != (fFlags | RTLOGGRPFLAGS_ENABLED))
     4161        &&  (*(pLoggerInt->afGroups + iGroup) & (fFlags | RTLOGGRPFLAGS_ENABLED)) != (fFlags | RTLOGGRPFLAGS_ENABLED))
    41624162        return VINF_LOG_DISABLED;
    41634163
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r102874 r103066  
    426426            fContiguous = true;
    427427            for (iPage = 0; iPage < cPages; iPage++)
    428                 pMemLnx->apPages[iPage] = &paPages[iPage];
     428                *(pMemLnx->apPages + iPage) = &paPages[iPage];
    429429        }
    430430        else if (fContiguous)
     
    442442        for (iPage = 0; iPage < cPages; iPage++)
    443443        {
    444             pMemLnx->apPages[iPage] = alloc_page(fFlagsLnx | __GFP_NOWARN);
    445             if (RT_UNLIKELY(!pMemLnx->apPages[iPage]))
     444            *(pMemLnx->apPages + iPage) = alloc_page(fFlagsLnx | __GFP_NOWARN);
     445            if (RT_UNLIKELY(!*(pMemLnx->apPages + iPage)))
    446446            {
    447447                while (iPage-- > 0)
    448                     __free_page(pMemLnx->apPages[iPage]);
     448                    __free_page(*(pMemLnx->apPages + iPage));
    449449                rtR0MemObjDelete(&pMemLnx->Core);
    450450                return rcNoMem;
     
    623623        size_t iPage = pMemLnx->cPages;
    624624        while (iPage-- > 0)
    625             if (PageHighMem(pMemLnx->apPages[iPage]))
     625            if (PageHighMem(*(pMemLnx->apPages + iPage)))
    626626            {
    627627                fMustMap = true;
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