Changeset 103526 in vbox
- Timestamp:
- Feb 22, 2024 11:19:16 AM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VHD.cpp
r98103 r103526 428 428 } 429 429 430 if (pvBuf) 431 RTMemTmpFree(pvBuf); 430 RTMemTmpFree(pvBuf); 432 431 return rc; 433 432 } … … 756 755 rc = vdIfIoIntFileReadSync(pImage->pIfIo, pImage->pStorage, uDynamicDiskHeaderOffset, 757 756 &vhdDynamicDiskHeader, sizeof(VHDDynamicDiskHeader)); 757 if (RT_FAILURE(rc)) 758 return rc; 759 758 760 if (memcmp(vhdDynamicDiskHeader.Cookie, VHD_DYNAMIC_DISK_HEADER_COOKIE, VHD_DYNAMIC_DISK_HEADER_COOKIE_SIZE)) 759 761 return VERR_INVALID_PARAMETER; … … 859 861 860 862 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));865 863 if (RT_SUCCESS(rc)) 866 864 { 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 } 881 886 } 882 887 } … … 2537 2542 2538 2543 /* Write the new BAT in any case. */ 2539 rc = vhdFlushImage(pImage); 2544 int rc2 = vhdFlushImage(pImage); 2545 if (RT_SUCCESS(rc)) 2546 rc = rc2; 2540 2547 } while (0); 2541 2548 … … 2839 2846 u32ChkSum, u32ChkSumOld); 2840 2847 fRepairFooter = true; 2841 break;2842 2848 } 2843 2849 … … 2897 2903 u32ChkSum, u32ChkSumOld); 2898 2904 fRepairDynHeader = true; 2899 break;2900 2905 } 2901 2906
Note:
See TracChangeset
for help on using the changeset viewer.