VirtualBox

Changeset 72953 in vbox


Ignore:
Timestamp:
Jul 7, 2018 6:20:59 PM (7 years ago)
Author:
vboxsync
Message:

Runtime: Proper error handling (bugref:9188)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/isofs.cpp

    r69111 r72953  
    172172    while ((cbLeft > 0) && RT_SUCCESS(rc))
    173173    {
     174        AssertReturn(cbLeft >= sizeof(RTISOFSPATHTABLEHEADER), VERR_INVALID_PARAMETER);
    174175        size_t cbRead;
    175176        rc = RTFileRead(pFile->file, (RTISOFSPATHTABLEHEADER*)&header, sizeof(RTISOFSPATHTABLEHEADER), &cbRead);
    176         if (RT_FAILURE(rc))
     177        if (RT_FAILURE(rc) || cbRead == 0)
    177178            break;
    178179        cbLeft -= cbRead;
    179180        if (header.length)
    180181        {
    181             Assert(cbLeft >= header.length);
    182             Assert(header.length <= 31);
     182            AssertReturn(cbLeft >= header.length, VERR_INVALID_PARAMETER);
     183            AssertReturn(header.length <= 31, VERR_INVALID_PARAMETER);
    183184            /* Allocate and read in the actual path name. */
    184185            char *pszName = RTStrAlloc(header.length + 1);
     
    201202    }
    202203
    203     /* Transform path names into full paths. This is a bit ugly right now. */
    204     PRTISOFSPATHTABLEENTRY pNode = RTListGetLast(&pFile->listPaths, RTISOFSPATHTABLEENTRY, Node);
    205     while (   pNode
    206            && !RTListNodeIsFirst(&pFile->listPaths, &pNode->Node)
    207            && RT_SUCCESS(rc))
    208     {
    209         rc = rtIsoFsGetParentPathSub(&pFile->listPaths, pNode,
    210                                      pNode->path, &pNode->path_full);
    211         if (RT_SUCCESS(rc))
    212             pNode = RTListNodeGetPrev(&pNode->Node, RTISOFSPATHTABLEENTRY, Node);
     204    if (RT_SUCCESS(rc))
     205    {
     206        /* Transform path names into full paths. This is a bit ugly right now. */
     207        PRTISOFSPATHTABLEENTRY pNode = RTListGetLast(&pFile->listPaths, RTISOFSPATHTABLEENTRY, Node);
     208        while (   pNode
     209               && !RTListNodeIsFirst(&pFile->listPaths, &pNode->Node)
     210               && RT_SUCCESS(rc))
     211        {
     212            rc = rtIsoFsGetParentPathSub(&pFile->listPaths, pNode,
     213                                         pNode->path, &pNode->path_full);
     214            if (RT_SUCCESS(rc))
     215                pNode = RTListNodeGetPrev(&pNode->Node, RTISOFSPATHTABLEENTRY, Node);
     216        }
    213217    }
    214218
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