VirtualBox

Changeset 85678 in vbox for trunk/src


Ignore:
Timestamp:
Aug 10, 2020 8:18:04 PM (4 years ago)
Author:
vboxsync
Message:

IPRT/ldrMachO.cpp: Fix SegInfo.cbMapping nil value and checking for unmapped segments to make tstLdr-4 happy. bugref:9801

File:
1 edited

Legend:

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

    r85339 r85678  
    15521552                cSegmentsToAdjust--;
    15531553                pThis->aSegments[cSegmentsToAdjust].SegInfo.RVA = NIL_RTLDRADDR;
    1554                 pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = 0;
     1554                pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = NIL_RTLDRADDR;
    15551555                continue;
    15561556            }
     
    15641564            {
    15651565                cSegmentsToAdjust--;
    1566                 pThis->aSegments[cSegmentsToAdjust].SegInfo.RVA = NIL_RTLDRADDR;
    1567                 pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = 0;
     1566                pThis->aSegments[cSegmentsToAdjust].SegInfo.RVA      = NIL_RTLDRADDR;
     1567                pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = NIL_RTLDRADDR;
    15681568                continue;
    15691569            }
     
    44594459    uint32_t const cSegments  = pThis->cSegments;
    44604460    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
    4461     {
    4462         RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
    4463         if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
    4464             || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
    4465         {
    4466             *piSeg = iSeg;
    4467             *poffSeg = offSeg;
    4468             return VINF_SUCCESS;
    4469         }
    4470     }
     4461        if (pThis->aSegments[iSeg].SegInfo.RVA != NIL_RTLDRADDR)
     4462        {
     4463            Assert(pThis->aSegments[iSeg].SegInfo.cbMapped != NIL_RTLDRADDR);
     4464            RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
     4465            if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
     4466                || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
     4467            {
     4468                *piSeg = iSeg;
     4469                *poffSeg = offSeg;
     4470                return VINF_SUCCESS;
     4471            }
     4472        }
    44714473
    44724474    return VERR_LDR_INVALID_LINK_ADDRESS;
     
    44824484    uint32_t const cSegments  = pThis->cSegments;
    44834485    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
    4484     {
    4485         RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
    4486         if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
    4487             || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
    4488         {
    4489             *pRva = pThis->aSegments[iSeg].SegInfo.RVA + offSeg;
    4490             return VINF_SUCCESS;
    4491         }
    4492     }
     4486        if (pThis->aSegments[iSeg].SegInfo.RVA != NIL_RTLDRADDR)
     4487        {
     4488            Assert(pThis->aSegments[iSeg].SegInfo.cbMapped != NIL_RTLDRADDR);
     4489            RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
     4490            if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
     4491                || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
     4492            {
     4493                *pRva = pThis->aSegments[iSeg].SegInfo.RVA + offSeg;
     4494                return VINF_SUCCESS;
     4495            }
     4496        }
    44934497
    44944498    return VERR_LDR_INVALID_RVA;
     
    45064510        return VERR_LDR_INVALID_SEG_OFFSET;
    45074511    RTLDRMODMACHOSEG const *pSegment = &pThis->aSegments[iSeg];
     4512
     4513    if (pSegment->SegInfo.RVA == NIL_RTLDRADDR)
     4514        return VERR_LDR_INVALID_SEG_OFFSET;
    45084515
    45094516    if (   offSeg > pSegment->SegInfo.cbMapped
     
    45264533    uint32_t const cSegments  = pThis->cSegments;
    45274534    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
    4528     {
    4529         RTLDRADDR offSeg = Rva - pThis->aSegments[iSeg].SegInfo.RVA;
    4530         if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
    4531             || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
    4532         {
    4533             *piSeg = iSeg;
    4534             *poffSeg = offSeg;
    4535             return VINF_SUCCESS;
    4536         }
    4537     }
     4535        if (pThis->aSegments[iSeg].SegInfo.RVA != NIL_RTLDRADDR)
     4536        {
     4537            Assert(pThis->aSegments[iSeg].SegInfo.cbMapped != NIL_RTLDRADDR);
     4538            RTLDRADDR offSeg = Rva - pThis->aSegments[iSeg].SegInfo.RVA;
     4539            if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
     4540                || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
     4541            {
     4542                *piSeg = iSeg;
     4543                *poffSeg = offSeg;
     4544                return VINF_SUCCESS;
     4545            }
     4546        }
    45384547
    45394548    return VERR_LDR_INVALID_RVA;
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