VirtualBox

Changeset 103526 in vbox


Ignore:
Timestamp:
Feb 22, 2024 11:19:16 AM (11 months ago)
Author:
vboxsync
Message:

Storage/VHD.cpp: Some unused variable, bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VHD.cpp

    r98103 r103526  
    428428    }
    429429
    430     if (pvBuf)
    431         RTMemTmpFree(pvBuf);
     430    RTMemTmpFree(pvBuf);
    432431    return rc;
    433432}
     
    756755    rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, uDynamicDiskHeaderOffset,
    757756                               &vhdDynamicDiskHeader, sizeof(VHDDynamicDiskHeader));
     757    if (RT_FAILURE(rc))
     758        return rc;
     759
    758760    if (memcmp(vhdDynamicDiskHeader.Cookie, VHD_DYNAMIC_DISK_HEADER_COOKIE, VHD_DYNAMIC_DISK_HEADER_COOKIE_SIZE))
    759761        return VERR_INVALID_PARAMETER;
     
    859861
    860862    rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &FileSize);
    861     pImage->uCurrentEndOfFile = FileSize - sizeof(VHDFooter);
    862 
    863     rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, pImage->uCurrentEndOfFile,
    864                                &vhdFooter, sizeof(VHDFooter));
    865863    if (RT_SUCCESS(rc))
    866864    {
    867         if (memcmp(vhdFooter.Cookie, VHD_FOOTER_COOKIE, VHD_FOOTER_COOKIE_SIZE) != 0)
    868         {
    869             /*
    870              * There is also a backup header at the beginning in case the image got corrupted.
    871              * Such corrupted images are detected here to let the open handler repair it later.
    872              */
    873             rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, 0,
    874                                        &vhdFooter, sizeof(VHDFooter));
    875             if (RT_SUCCESS(rc))
    876             {
    877                 if (memcmp(vhdFooter.Cookie, VHD_FOOTER_COOKIE, VHD_FOOTER_COOKIE_SIZE) != 0)
    878                     rc = VERR_VD_VHD_INVALID_HEADER;
    879                 else
    880                     rc = VERR_VD_IMAGE_CORRUPTED;
     865        pImage->uCurrentEndOfFile = FileSize - sizeof(VHDFooter);
     866
     867        rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, pImage->uCurrentEndOfFile,
     868                                   &vhdFooter, sizeof(VHDFooter));
     869        if (RT_SUCCESS(rc))
     870        {
     871            if (memcmp(vhdFooter.Cookie, VHD_FOOTER_COOKIE, VHD_FOOTER_COOKIE_SIZE) != 0)
     872            {
     873                /*
     874                 * There is also a backup header at the beginning in case the image got corrupted.
     875                 * Such corrupted images are detected here to let the open handler repair it later.
     876                 */
     877                rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, 0,
     878                                           &vhdFooter, sizeof(VHDFooter));
     879                if (RT_SUCCESS(rc))
     880                {
     881                    if (memcmp(vhdFooter.Cookie, VHD_FOOTER_COOKIE, VHD_FOOTER_COOKIE_SIZE) != 0)
     882                        rc = VERR_VD_VHD_INVALID_HEADER;
     883                    else
     884                        rc = VERR_VD_IMAGE_CORRUPTED;
     885                }
    881886            }
    882887        }
     
    25372542
    25382543        /* Write the new BAT in any case. */
    2539         rc = vhdFlushImage(pImage);
     2544        int rc2 = vhdFlushImage(pImage);
     2545        if (RT_SUCCESS(rc))
     2546            rc = rc2;
    25402547    } while (0);
    25412548
     
    28392846                             u32ChkSum, u32ChkSumOld);
    28402847            fRepairFooter = true;
    2841             break;
    28422848        }
    28432849
     
    28972903                                 u32ChkSum, u32ChkSumOld);
    28982904                fRepairDynHeader = true;
    2899                 break;
    29002905            }
    29012906
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