VirtualBox

Changeset 73097 in vbox for trunk/src/VBox/Runtime/common/fs


Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (7 years ago)
Author:
vboxsync
Message:

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

Location:
trunk/src/VBox/Runtime/common/fs
Files:
7 edited

Legend:

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

    r70422 r73097  
    782782    {
    783783        default: AssertFailed(); RT_FALL_THRU();
    784         case RTCMDLSTIME_MTIME: offTime = RT_OFFSETOF(RTCMDLSENTRY, Info.ModificationTime); break;
    785         case RTCMDLSTIME_BTIME: offTime = RT_OFFSETOF(RTCMDLSENTRY, Info.BirthTime); break;
    786         case RTCMDLSTIME_CTIME: offTime = RT_OFFSETOF(RTCMDLSENTRY, Info.ChangeTime); break;
    787         case RTCMDLSTIME_ATIME: offTime = RT_OFFSETOF(RTCMDLSENTRY, Info.AccessTime); break;
     784        case RTCMDLSTIME_MTIME: offTime = RT_UOFFSETOF(RTCMDLSENTRY, Info.ModificationTime); break;
     785        case RTCMDLSTIME_BTIME: offTime = RT_UOFFSETOF(RTCMDLSENTRY, Info.BirthTime); break;
     786        case RTCMDLSTIME_CTIME: offTime = RT_UOFFSETOF(RTCMDLSENTRY, Info.ChangeTime); break;
     787        case RTCMDLSTIME_ATIME: offTime = RT_UOFFSETOF(RTCMDLSENTRY, Info.AccessTime); break;
    788788    }
    789789
     
    10271027            && *pszName)
    10281028        {
    1029             PRTCMDLSCOLLECTION pCollection = (PRTCMDLSCOLLECTION)RTMemAllocZ(RT_OFFSETOF(RTCMDLSCOLLECTION, szName[1]));
     1029            PRTCMDLSCOLLECTION pCollection = (PRTCMDLSCOLLECTION)RTMemAllocZ(RT_UOFFSETOF(RTCMDLSCOLLECTION, szName[1]));
    10301030            if (!pCollection)
    10311031            {
     
    10401040    /* Add new collection. */
    10411041    size_t cbName = strlen(pszName) + 1;
    1042     PRTCMDLSCOLLECTION pCollection = (PRTCMDLSCOLLECTION)RTMemAllocZ(RT_OFFSETOF(RTCMDLSCOLLECTION, szName[cbName]));
     1042    PRTCMDLSCOLLECTION pCollection = (PRTCMDLSCOLLECTION)RTMemAllocZ(RT_UOFFSETOF_DYN(RTCMDLSCOLLECTION, szName[cbName]));
    10431043    if (pCollection)
    10441044    {
     
    10831083    size_t const cbGroup  = pszGroup  ? strlen(pszGroup)  + 1 : 0;
    10841084    size_t const cbTarget = pszTarget ? strlen(pszTarget) + 1 : 0;
    1085     size_t const cbEntry  = RT_OFFSETOF(RTCMDLSENTRY, szName[cchEntry + 1 + cbOwner + cbGroup + cbTarget]);
     1085    size_t const cbEntry  = RT_UOFFSETOF_DYN(RTCMDLSENTRY, szName[cchEntry + 1 + cbOwner + cbGroup + cbTarget]);
    10861086    PRTCMDLSENTRY pEntry = (PRTCMDLSENTRY)RTMemAlloc(cbEntry);
    10871087    if (pEntry)
  • trunk/src/VBox/Runtime/common/fs/ext2vfs.cpp

    r69861 r73097  
    9999    if (!pBlkGrpDesc)
    100100    {
    101         size_t cbBlkDesc = RT_OFFSETOF(RTFILESYSTEMEXTBLKGRP, abBlockBitmap[cbBlockBitmap]);
     101        size_t cbBlkDesc = RT_UOFFSETOF_DYN(RTFILESYSTEMEXTBLKGRP, abBlockBitmap[cbBlockBitmap]);
    102102        pBlkGrpDesc = (PRTFILESYSTEMEXTBLKGRP)RTMemAllocZ(cbBlkDesc);
    103103        if (!pBlkGrpDesc)
  • trunk/src/VBox/Runtime/common/fs/fatvfs.cpp

    r72584 r73097  
    824824     */
    825825    PRTFSFATCLUSTERMAPCACHE pFatCache;
    826     pThis->pFatCache = pFatCache = (PRTFSFATCLUSTERMAPCACHE)RTMemAllocZ(RT_OFFSETOF(RTFSFATCLUSTERMAPCACHE, aEntries[cEntries]));
     826    pFatCache = (PRTFSFATCLUSTERMAPCACHE)RTMemAllocZ(RT_UOFFSETOF_DYN(RTFSFATCLUSTERMAPCACHE, aEntries[cEntries]));
     827    pThis->pFatCache = pFatCache;
    827828    if (!pFatCache)
    828829        return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "Failed to allocate FAT cache");
     
    25712572    { /* ObjSet */
    25722573        RTVFSOBJSETOPS_VERSION,
    2573         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     2574        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    25742575        rtFsFatFile_SetMode,
    25752576        rtFsFatFile_SetTimes,
     
    44124413    if (pThis->offDir < 2)
    44134414    {
    4414         size_t cbNeeded = RT_OFFSETOF(RTDIRENTRYEX, szName[pThis->offDir + 2]);
     4415        size_t cbNeeded = RT_UOFFSETOF_DYN(RTDIRENTRYEX, szName[pThis->offDir + 2]);
    44154416        if (cbNeeded < *pcbDirEntry)
    44164417            *pcbDirEntry = cbNeeded;
     
    45544555                if (!fLongName)
    45554556                    cchName = rtFsFatDir_CalcUtf8LengthForDirEntry(pShared, &paEntries[iEntry].Entry);
    4556                 size_t cbNeeded = RT_OFFSETOF(RTDIRENTRYEX, szName[cchName + 1]);
     4557                size_t cbNeeded = RT_UOFFSETOF_DYN(RTDIRENTRYEX, szName[cchName + 1]);
    45574558                if (cbNeeded <= *pcbDirEntry)
    45584559                    *pcbDirEntry = cbNeeded;
     
    46264627    { /* ObjSet */
    46274628        RTVFSOBJSETOPS_VERSION,
    4628         RT_OFFSETOF(RTVFSDIROPS, Obj) - RT_OFFSETOF(RTVFSDIROPS, ObjSet),
     4629        RT_UOFFSETOF(RTVFSDIROPS, ObjSet) - RT_UOFFSETOF(RTVFSDIROPS, Obj),
    46294630        rtFsFatDir_SetMode,
    46304631        rtFsFatDir_SetTimes,
     
    50315032    Assert(offFirstZero >= RT_UOFFSETOF(FATBOOTSECTOR, Bpb));
    50325033    uint32_t const cbZeroPad    = RT_MIN(offJump - offFirstZero,
    5033                                          sizeof(pBootSector->Bpb.Bpb20) - (offFirstZero - RT_OFFSETOF(FATBOOTSECTOR, Bpb)));
     5034                                         sizeof(pBootSector->Bpb.Bpb20) - (offFirstZero - RT_UOFFSETOF(FATBOOTSECTOR, Bpb)));
    50345035
    50355036    if (!ASMMemIsAllU8((uint8_t const *)pBootSector + offFirstZero, cbZeroPad, 0))
     
    53875388             && pBootSector->abJmp[2] <= 0x7f)
    53885389        offJmp = RT_MIN(127, RT_MAKE_U16(pBootSector->abJmp[1], pBootSector->abJmp[2]));
    5389     uint8_t const cbMaxBpb = offJmp - RT_OFFSETOF(FATBOOTSECTOR, Bpb);
     5390    uint8_t const cbMaxBpb = offJmp - RT_UOFFSETOF(FATBOOTSECTOR, Bpb);
    53905391
    53915392    /*
     
    54445445    if (   (   sizeof(FAT32EBPB) <= cbMaxBpb
    54455446            && pBootSector->Bpb.Fat32Ebpb.bExtSignature == FATEBPB_SIGNATURE)
    5446         || (   RT_OFFSETOF(FAT32EBPB, achLabel) <= cbMaxBpb
     5447        || (   RT_UOFFSETOF(FAT32EBPB, achLabel) <= cbMaxBpb
    54475448            && pBootSector->Bpb.Fat32Ebpb.bExtSignature == FATEBPB_SIGNATURE_OLD) )
    54485449    {
     
    54605461        if (   (   sizeof(FATEBPB) <= cbMaxBpb
    54615462                && pBootSector->Bpb.Ebpb.bExtSignature == FATEBPB_SIGNATURE)
    5462             || (   RT_OFFSETOF(FATEBPB, achLabel) <= cbMaxBpb
     5463            || (   RT_UOFFSETOF(FATEBPB, achLabel) <= cbMaxBpb
    54635464                && pBootSector->Bpb.Ebpb.bExtSignature == FATEBPB_SIGNATURE_OLD) )
    54645465        {
  • trunk/src/VBox/Runtime/common/fs/isomaker.cpp

    r70155 r73097  
    9999 *        is the case in rtFsIsoMakerNormalizeNameForNamespace. */
    100100#define RTFSISOMAKER_CALC_PATHREC_SIZE(a_cbNameInDirRec) \
    101     ( RT_UOFFSETOF(ISO9660PATHREC, achDirId[(a_cbNameInDirRec) + ((a_cbNameInDirRec) & 1)]) )
     101    ( RT_UOFFSETOF_DYN(ISO9660PATHREC, achDirId[(a_cbNameInDirRec) + ((a_cbNameInDirRec) & 1)]) )
    102102
    103103
     
    660660} g_aRTFsIsoNamespaces[] =
    661661{
    662     {   RTFSISOMAKER_NAMESPACE_ISO_9660, RT_OFFSETOF(RTFSISOMAKERINT, PrimaryIso), RT_OFFSETOF(RTFSISOMAKEROBJ, pPrimaryName), "iso-9660" },
    663     {   RTFSISOMAKER_NAMESPACE_JOLIET,   RT_OFFSETOF(RTFSISOMAKERINT, Joliet),     RT_OFFSETOF(RTFSISOMAKEROBJ, pJolietName),  "joliet" },
    664     {   RTFSISOMAKER_NAMESPACE_UDF,      RT_OFFSETOF(RTFSISOMAKERINT, Udf),        RT_OFFSETOF(RTFSISOMAKEROBJ, pUdfName),     "udf" },
    665     {   RTFSISOMAKER_NAMESPACE_HFS,      RT_OFFSETOF(RTFSISOMAKERINT, Hfs),        RT_OFFSETOF(RTFSISOMAKEROBJ, pHfsName),     "hfs" },
     662    {   RTFSISOMAKER_NAMESPACE_ISO_9660, RT_UOFFSETOF(RTFSISOMAKERINT, PrimaryIso), RT_UOFFSETOF(RTFSISOMAKEROBJ, pPrimaryName), "iso-9660" },
     663    {   RTFSISOMAKER_NAMESPACE_JOLIET,   RT_UOFFSETOF(RTFSISOMAKERINT, Joliet),     RT_UOFFSETOF(RTFSISOMAKEROBJ, pJolietName),  "joliet" },
     664    {   RTFSISOMAKER_NAMESPACE_UDF,      RT_UOFFSETOF(RTFSISOMAKERINT, Udf),        RT_UOFFSETOF(RTFSISOMAKEROBJ, pUdfName),     "udf" },
     665    {   RTFSISOMAKER_NAMESPACE_HFS,      RT_UOFFSETOF(RTFSISOMAKERINT, Hfs),        RT_UOFFSETOF(RTFSISOMAKEROBJ, pHfsName),     "hfs" },
    666666};
    667667
     
    36113611     * Do the adding.
    36123612     */
    3613     PRTFSISOMAKERSYMLINK pSymlink = (PRTFSISOMAKERSYMLINK)RTMemAllocZ(RT_UOFFSETOF(RTFSISOMAKERSYMLINK, szTarget[cchTarget + 1]));
     3613    PRTFSISOMAKERSYMLINK pSymlink = (PRTFSISOMAKERSYMLINK)RTMemAllocZ(RT_UOFFSETOF_DYN(RTFSISOMAKERSYMLINK, szTarget[cchTarget + 1]));
    36143614    AssertReturn(pSymlink, VERR_NO_MEMORY);
    36153615    int rc = rtFsIsoMakerInitCommonObj(pThis, &pSymlink->Core, RTFSISOMAKEROBJTYPE_SYMLINK, pObjInfo);
     
    58825882                size_t         cchThis = RT_MIN(cchSrc, ISO9660RRIPNM_MAX_NAME_LEN);
    58835883                PISO9660RRIPNM pNM     = (PISO9660RRIPNM)pbSys;
    5884                 Assert(cbSys >= RT_UOFFSETOF(ISO9660RRIPNM, achName[cchThis]));
     5884                Assert(cbSys >= RT_UOFFSETOF_DYN(ISO9660RRIPNM, achName[cchThis]));
    58855885                pNM->Hdr.bSig1      = ISO9660RRIPNM_SIG1;
    58865886                pNM->Hdr.bSig2      = ISO9660RRIPNM_SIG2;
     
    73797379    { /* ObjSet */
    73807380        RTVFSOBJSETOPS_VERSION,
    7381         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     7381        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    73827382        NULL /*SetMode*/,
    73837383        NULL /*SetTimes*/,
  • trunk/src/VBox/Runtime/common/fs/isomakerimport.cpp

    r71013 r73097  
    732732                    || pUnion->SP.bCheck1   != ISO9660SUSPSP_CHECK1
    733733                    || pUnion->SP.bCheck2   != ISO9660SUSPSP_CHECK2
    734                     || pUnion->SP.cbSkip > UINT8_MAX - RT_OFFSETOF(ISO9660DIRREC, achFileId[1]))
     734                    || pUnion->SP.cbSkip > UINT8_MAX - RT_UOFFSETOF(ISO9660DIRREC, achFileId[1]))
    735735                    LogRel(("rtFsIsoImport/Rock: Malformed 'SP' entry: cbEntry=%#x (vs %#x), bVersion=%#x (vs %#x), bCheck1=%#x (vs %#x), bCheck2=%#x (vs %#x), cbSkip=%#x (vs max %#x)\n",
    736736                            pUnion->Hdr.cbEntry, ISO9660SUSPSP_LEN, pUnion->Hdr.bVersion, ISO9660SUSPSP_VER,
    737737                            pUnion->SP.bCheck1, ISO9660SUSPSP_CHECK1, pUnion->SP.bCheck2, ISO9660SUSPSP_CHECK2,
    738                             pUnion->SP.cbSkip, UINT8_MAX - RT_OFFSETOF(ISO9660DIRREC, achFileId[1]) ));
     738                            pUnion->SP.cbSkip, UINT8_MAX - RT_UOFFSETOF(ISO9660DIRREC, achFileId[1]) ));
    739739                else if (!fIsFirstDirRec)
    740740                    LogRel(("rtFsIsoImport/Rock: Ignorining 'SP' entry in non-root directory record\n"));
     
    750750
    751751            case MAKE_SIG(ISO9660SUSPER_SIG1, ISO9660SUSPER_SIG2): /* ER */
    752                 if (   pUnion->Hdr.cbEntry >   RT_OFFSETOF(ISO9660SUSPER, achPayload) + (uint32_t)pUnion->ER.cchIdentifier
     752                if (   pUnion->Hdr.cbEntry >   RT_UOFFSETOF(ISO9660SUSPER, achPayload) + (uint32_t)pUnion->ER.cchIdentifier
    753753                                             + (uint32_t)pUnion->ER.cchDescription   + (uint32_t)pUnion->ER.cchSource
    754754                    || pUnion->Hdr.bVersion != ISO9660SUSPER_VER)
     
    914914            case MAKE_SIG(ISO9660RRIPSL_SIG1, ISO9660RRIPSL_SIG2): /* SL */
    915915                if (   pUnion->SL.Hdr.bVersion != ISO9660RRIPSL_VER
    916                     || pUnion->SL.Hdr.cbEntry < RT_OFFSETOF(ISO9660RRIPSL, abComponents[2])
     916                    || pUnion->SL.Hdr.cbEntry < RT_UOFFSETOF(ISO9660RRIPSL, abComponents[2])
    917917                    || (pUnion->SL.fFlags & ~ISO9660RRIP_SL_F_CONTINUE)
    918918                    || (pUnion->SL.abComponents[0] & ISO9660RRIP_SL_C_RESERVED_MASK) )
    919919                    LogRel(("rtFsIsoImport/Rock: Malformed 'SL' entry: cbEntry=%#x (vs %#x), bVersion=%#x (vs %#x) fFlags=%#x comp[0].fFlags=%#x\n",
    920                             pUnion->SL.Hdr.cbEntry, RT_OFFSETOF(ISO9660RRIPSL, abComponents[2]),
     920                            pUnion->SL.Hdr.cbEntry, RT_UOFFSETOF(ISO9660RRIPSL, abComponents[2]),
    921921                            pUnion->SL.Hdr.bVersion, ISO9660RRIPSL_VER, pUnion->SL.fFlags, pUnion->SL.abComponents[0]));
    922922                else if (pThis->fSeenLastSL)
     
    928928                    size_t         offDst    = strlen(pThis->szRockSymlinkTargetBuf);
    929929                    uint8_t const *pbSrc     = &pUnion->SL.abComponents[0];
    930                     uint8_t        cbSrcLeft = pUnion->SL.Hdr.cbEntry - RT_OFFSETOF(ISO9660RRIPSL, abComponents);
     930                    uint8_t        cbSrcLeft = pUnion->SL.Hdr.cbEntry - RT_UOFFSETOF(ISO9660RRIPSL, abComponents);
    931931                    while (cbSrcLeft >= 2)
    932932                    {
     
    10191019            case MAKE_SIG(ISO9660RRIPNM_SIG1, ISO9660RRIPNM_SIG2): /* NM */
    10201020                if (   pUnion->NM.Hdr.bVersion != ISO9660RRIPNM_VER
    1021                     || pUnion->NM.Hdr.cbEntry < RT_OFFSETOF(ISO9660RRIPNM, achName)
     1021                    || pUnion->NM.Hdr.cbEntry < RT_UOFFSETOF(ISO9660RRIPNM, achName)
    10221022                    || (pUnion->NM.fFlags & ISO9660RRIP_NM_F_RESERVED_MASK) )
    10231023                    LogRel(("rtFsIsoImport/Rock: Malformed 'NM' entry: cbEntry=%#x (vs %#x), bVersion=%#x (vs %#x) fFlags=%#x %.*Rhxs\n",
    1024                             pUnion->NM.Hdr.cbEntry, RT_OFFSETOF(ISO9660RRIPNM, achName),
     1024                            pUnion->NM.Hdr.cbEntry, RT_UOFFSETOF(ISO9660RRIPNM, achName),
    10251025                            pUnion->NM.Hdr.bVersion, ISO9660RRIPNM_VER, pUnion->NM.fFlags,
    1026                             pUnion->NM.Hdr.cbEntry - RT_MIN(pUnion->NM.Hdr.cbEntry, RT_OFFSETOF(ISO9660RRIPNM, achName)),
     1026                            pUnion->NM.Hdr.cbEntry - RT_MIN(pUnion->NM.Hdr.cbEntry, RT_UOFFSETOF(ISO9660RRIPNM, achName)),
    10271027                            &pUnion->NM.achName[0] ));
    10281028                else if (pThis->fSeenLastNM)
     
    10321032                    pThis->fSeenLastNM = !(pUnion->NM.fFlags & ISO9660RRIP_NM_F_CONTINUE);
    10331033
    1034                     uint8_t const cchName = pUnion->NM.Hdr.cbEntry - (uint8_t)RT_OFFSETOF(ISO9660RRIPNM, achName);
     1034                    uint8_t const cchName = pUnion->NM.Hdr.cbEntry - (uint8_t)RT_UOFFSETOF(ISO9660RRIPNM, achName);
    10351035                    if (pUnion->NM.fFlags & (ISO9660RRIP_NM_F_CURRENT | ISO9660RRIP_NM_F_PARENT))
    10361036                    {
     
    11631163                               ISO9660_GET_ENDIAN(&pDirRec->offExtent), pThis->cBlocksInPrimaryVolumeSpace);
    11641164
    1165     if (pDirRec->cbDirRec < RT_OFFSETOF(ISO9660DIRREC, achFileId) + pDirRec->bFileIdLength)
     1165    if (pDirRec->cbDirRec < RT_UOFFSETOF(ISO9660DIRREC, achFileId) + pDirRec->bFileIdLength)
    11661166        return rtFsIsoImpError(pThis, VERR_ISOMK_IMPORT_BAD_DIR_REC_LENGTH,
    11671167                               "Dir record size is too small: %#x (min %#x)",
    1168                                pDirRec->cbDirRec, RT_OFFSETOF(ISO9660DIRREC, achFileId) + pDirRec->bFileIdLength);
     1168                               pDirRec->cbDirRec, RT_UOFFSETOF(ISO9660DIRREC, achFileId) + pDirRec->bFileIdLength);
    11691169    if (pDirRec->cbDirRec > cbMax)
    11701170        return rtFsIsoImpError(pThis, VERR_ISOMK_IMPORT_BAD_DIR_REC_LENGTH,
     
    18301830                               ISO9660_GET_ENDIAN(&pDirRec->offExtent), pThis->cBlocksInPrimaryVolumeSpace);
    18311831
    1832     if (pDirRec->cbDirRec < RT_OFFSETOF(ISO9660DIRREC, achFileId))
     1832    if (pDirRec->cbDirRec < RT_UOFFSETOF(ISO9660DIRREC, achFileId))
    18331833        return rtFsIsoImpError(pThis, VERR_ISOMK_IMPORT_BAD_ROOT_DIR_REC_LENGTH,
    18341834                               "Root dir record size is too small: %#x (min %#x)",
    1835                                pDirRec->cbDirRec, RT_OFFSETOF(ISO9660DIRREC, achFileId));
     1835                               pDirRec->cbDirRec, RT_UOFFSETOF(ISO9660DIRREC, achFileId));
    18361836
    18371837    if (!(pDirRec->fFileFlags & ISO9660_FILE_FLAGS_DIRECTORY))
  • trunk/src/VBox/Runtime/common/fs/isovfs.cpp

    r69977 r73097  
    12291229     * Basic sanity checking of what we use.
    12301230     */
    1231     if (     RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs + pFileEntry->cbAllocDescs
     1231    if (     RT_UOFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs + pFileEntry->cbAllocDescs
    12321232           > pVol->Udf.VolInfo.cbBlock
    12331233        || (pFileEntry->cbExtAttribs & 3) != 0
     
    12751275                                                idxDefaultPart,
    12761276                                                  ((uint64_t)pFileEntry->Tag.offTag << pVol->Udf.VolInfo.cShiftBlock)
    1277                                                 + RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs,
     1277                                                + RT_UOFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs,
    12781278                                                pVol);
    12791279        if (RT_SUCCESS(rc))
     
    13811381     * Basic sanity checking of what we use.
    13821382     */
    1383     if (     RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs + pFileEntry->cbAllocDescs
     1383    if (     RT_UOFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs + pFileEntry->cbAllocDescs
    13841384           > pVol->Udf.VolInfo.cbBlock
    13851385        || (pFileEntry->cbExtAttribs & 3) != 0
     
    14311431                                                idxDefaultPart,
    14321432                                                  ((uint64_t)pFileEntry->Tag.offTag << pVol->Udf.VolInfo.cShiftBlock)
    1433                                                 + RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs,
     1433                                                + RT_UOFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs,
    14341434                                                pVol);
    14351435        if (RT_SUCCESS(rc))
     
    21532153    { /* ObjSet */
    21542154        RTVFSOBJSETOPS_VERSION,
    2155         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     2155        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    21562156        NULL /*SetMode*/,
    21572157        NULL /*SetTimes*/,
     
    34303430    { /* ObjSet */
    34313431        RTVFSOBJSETOPS_VERSION,
    3432         RT_OFFSETOF(RTVFSDIROPS, Obj) - RT_OFFSETOF(RTVFSDIROPS, ObjSet),
     3432        RT_UOFFSETOF(RTVFSDIROPS, ObjSet) - RT_UOFFSETOF(RTVFSDIROPS, Obj),
    34333433        NULL /*SetMode*/,
    34343434        NULL /*SetTimes*/,
     
    35493549                  wszName));
    35503550
    3551             uint32_t offSysUse = RT_OFFSETOF(ISO9660DIRREC, achFileId[pDirRec->bFileIdLength]) + !(pDirRec->bFileIdLength & 1);
     3551            uint32_t offSysUse = RT_UOFFSETOF_DYN(ISO9660DIRREC, achFileId[pDirRec->bFileIdLength])
     3552                               + !(pDirRec->bFileIdLength & 1);
    35523553            if (offSysUse < pDirRec->cbDirRec)
    35533554            {
     
    36313632    {
    36323633        uint32_t offDesc = 0;
    3633         while (offDesc + RT_OFFSETOF(UDFFILEIDDESC, abImplementationUse) < pThis->cbDir)
     3634        while (offDesc + RT_UOFFSETOF(UDFFILEIDDESC, abImplementationUse) < pThis->cbDir)
    36343635        {
    36353636            PCUDFFILEIDDESC pFid  = (PCUDFFILEIDDESC)&pThis->pbDir[offDesc];
     
    53685369        Log2(("ISO9660:  RootDir.RecTime.bFileIdLength:      %RX8\n", pVolDesc->RootDir.DirRec.bFileIdLength));
    53695370        Log2(("ISO9660:  RootDir.RecTime.achFileId:          '%.*s'\n", pVolDesc->RootDir.DirRec.bFileIdLength, pVolDesc->RootDir.DirRec.achFileId));
    5370         uint32_t offSysUse = RT_OFFSETOF(ISO9660DIRREC, achFileId[pVolDesc->RootDir.DirRec.bFileIdLength])
     5371        uint32_t offSysUse = RT_UOFFSETOF_DYN(ISO9660DIRREC, achFileId[pVolDesc->RootDir.DirRec.bFileIdLength])
    53715372                           + !(pVolDesc->RootDir.DirRec.bFileIdLength & 1);
    53725373        if (offSysUse < pVolDesc->RootDir.DirRec.cbDirRec)
     
    53925393                                   PISO9660DIRREC pDstRootDir, PRTERRINFO pErrInfo)
    53935394{
    5394     if (pRootDir->cbDirRec < RT_OFFSETOF(ISO9660DIRREC, achFileId))
     5395    if (pRootDir->cbDirRec < RT_UOFFSETOF(ISO9660DIRREC, achFileId))
    53955396        return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT, "Root dir record size is too small: %#x (min %#x)",
    5396                                    pRootDir->cbDirRec, RT_OFFSETOF(ISO9660DIRREC, achFileId));
     5397                                   pRootDir->cbDirRec, RT_UOFFSETOF(ISO9660DIRREC, achFileId));
    53975398
    53985399    if (!(pRootDir->fFileFlags & ISO9660_FILE_FLAGS_DIRECTORY))
     
    54945495     * ... and the root directory record.
    54955496     */
    5496     *poffRootDirRec = offVolDesc + RT_OFFSETOF(ISO9660PRIMARYVOLDESC, RootDir.DirRec);
     5497    *poffRootDirRec = offVolDesc + RT_UOFFSETOF(ISO9660PRIMARYVOLDESC, RootDir.DirRec);
    54975498    return rtFsIsoVolHandleRootDir(pThis, &pVolDesc->RootDir.DirRec, pRootDir, pErrInfo);
    54985499}
     
    55715572    if (RT_SUCCESS(rc))
    55725573    {
    5573         *poffRootDirRec = offVolDesc + RT_OFFSETOF(ISO9660SUPVOLDESC, RootDir.DirRec);
     5574        *poffRootDirRec = offVolDesc + RT_UOFFSETOF(ISO9660SUPVOLDESC, RootDir.DirRec);
    55745575        *pbUcs2Level    = pVolDesc->abEscapeSequences[2] == ISO9660_JOLIET_ESC_SEQ_2_LEVEL_1 ? 1
    55755576                        : pVolDesc->abEscapeSequences[2] == ISO9660_JOLIET_ESC_SEQ_2_LEVEL_2 ? 2 : 3;
  • trunk/src/VBox/Runtime/common/fs/ntfsvfs.cpp

    r72585 r73097  
    764764                                    Log2(("NTFS:     cwcFilename        %#x\n", pInfo->cwcFilename));
    765765                                    Log2(("NTFS:     fFilenameType      %#x\n", pInfo->fFilenameType));
    766                                     if (RT_UOFFSETOF(NTFSATFILENAME, wszFilename[pInfo->cwcFilename]) <= cbValue)
     766                                    if (RT_UOFFSETOF_DYN(NTFSATFILENAME, wszFilename[pInfo->cwcFilename]) <= cbValue)
    767767                                        Log2(("NTFS:     wszFilename       '%.*ls'\n", pInfo->cwcFilename, pInfo->wszFilename ));
    768768                                    else
     
    770770                                }
    771771                                else
    772                                     Log2(("NTFS:     Error! cbValue=%#x is smaller than expected (%#x) for NTFSATFILENAME!\n",
    773                                           cbValue, RT_OFFSETOF(NTFSATFILENAME, wszFilename) ));
     772                                    Log2(("NTFS:     Error! cbValue=%#x is smaller than expected (%#zx) for NTFSATFILENAME!\n",
     773                                          cbValue, RT_UOFFSETOF(NTFSATFILENAME, wszFilename) ));
    774774                                break;
    775775                            }
     
    21382138        if (   pFilename
    21392139            && pFilename->cwcFilename >= 4
    2140             && RT_UOFFSETOF(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) <= cbFilename)
     2140            && RT_UOFFSETOF_DYN(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) <= cbFilename)
    21412141        {
    21422142            PCRTUTF16 pwcExt = &pFilename->wszFilename[pFilename->cwcFilename - 4];
     
    26182618    { /* ObjSet */
    26192619        RTVFSOBJSETOPS_VERSION,
    2620         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     2620        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    26212621        rtFsNtfsFile_SetMode,
    26222622        rtFsNtfsFile_SetTimes,
     
    28202820            Log2(("NTFS:             cwcFilename        %#x\n", pFilename->cwcFilename));
    28212821            Log2(("NTFS:             fFilenameType      %#x\n", pFilename->fFilenameType));
    2822             if (RT_UOFFSETOF(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) <= RT_LE2H_U16(pEntryHdr->cbKey))
     2822            if (RT_UOFFSETOF_DYN(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) <= RT_LE2H_U16(pEntryHdr->cbKey))
    28232823                Log2(("NTFS:             wszFilename       '%.*ls'\n", pFilename->cwcFilename, pFilename->wszFilename ));
    28242824            else
     
    29802980        {
    29812981            PCNTFSATFILENAME pFilename = (PCNTFSATFILENAME)(pEntryHdr + 1);
    2982             if (RT_UOFFSETOF(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) > cbKey)
     2982            if (RT_UOFFSETOF_DYN(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]) > cbKey)
    29832983                return RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT,
    29842984                                               "%s: Entry #%u filename is out of bounds: cwcFilename=%#x -> %#x key, max %#x",
    29852985                                               pszWhat, iEntry, pFilename->cwcFilename,
    2986                                                RT_UOFFSETOF(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]), cbKey);
     2986                                               RT_UOFFSETOF_DYN(NTFSATFILENAME, wszFilename[pFilename->cwcFilename]), cbKey);
    29872987        }
    29882988
     
    41634163        {
    41644164
    4165             *pcbDirEntry = RT_UOFFSETOF(RTDIRENTRYEX, szName[pThis->paEnumStack[0].iNext + 2]);
     4165            *pcbDirEntry = RT_UOFFSETOF_DYN(RTDIRENTRYEX, szName[pThis->paEnumStack[0].iNext + 2]);
    41664166            if (*pcbDirEntry > cbDirEntry)
    41674167                return VERR_BUFFER_OVERFLOW;
     
    42554255                                rc, pFilename->cwcFilename * sizeof(RTUTF16), pFilename->wszFilename));
    42564256                    }
    4257                     *pcbDirEntry = RT_UOFFSETOF(RTDIRENTRYEX, szName[cchFilename + 1]);
     4257                    *pcbDirEntry = RT_UOFFSETOF_DYN(RTDIRENTRYEX, szName[cchFilename + 1]);
    42584258                    if (*pcbDirEntry > cbDirEntry)
    42594259                    {
     
    44034403    { /* ObjSet */
    44044404        RTVFSOBJSETOPS_VERSION,
    4405         RT_OFFSETOF(RTVFSDIROPS, Obj) - RT_OFFSETOF(RTVFSDIROPS, ObjSet),
     4405        RT_UOFFSETOF(RTVFSDIROPS, ObjSet) - RT_UOFFSETOF(RTVFSDIROPS, Obj),
    44064406        rtFsNtfsDir_SetMode,
    44074407        rtFsNtfsDir_SetTimes,
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