Changeset 94912 in vbox for trunk/src/VBox/Main/src-all/ExtPackUtil.cpp
- Timestamp:
- May 8, 2022 7:05:31 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/ExtPackUtil.cpp
r94714 r94912 341 341 */ 342 342 RTFSOBJINFO ObjInfo; 343 int rc = RTVfsFileQueryInfo(hVfsFile, &ObjInfo, RTFSOBJATTRADD_UNIX);344 if (RT_FAILURE( rc))345 return &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileQueryInfo failed: %Rrc"), rc);343 int vrc = RTVfsFileQueryInfo(hVfsFile, &ObjInfo, RTFSOBJATTRADD_UNIX); 344 if (RT_FAILURE(vrc)) 345 return &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileQueryInfo failed: %Rrc"), vrc); 346 346 if (a_pObjInfo) 347 347 *a_pObjInfo = ObjInfo; … … 359 359 360 360 /* Rewind to the start of the file. */ 361 rc = RTVfsFileSeek(hVfsFile, 0, RTFILE_SEEK_BEGIN, NULL);362 if (RT_FAILURE( rc))363 return &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileSeek(,0,BEGIN) failed: %Rrc"), rc);361 vrc = RTVfsFileSeek(hVfsFile, 0, RTFILE_SEEK_BEGIN, NULL); 362 if (RT_FAILURE(vrc)) 363 return &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileSeek(,0,BEGIN) failed: %Rrc"), vrc); 364 364 365 365 /* Allocate memory and read the file content into it. */ … … 369 369 370 370 RTCString *pstrErr = NULL; 371 rc = RTVfsFileRead(hVfsFile, pvFile, cbFile, NULL);372 if (RT_FAILURE( rc))373 pstrErr = &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileRead failed: %Rrc"), rc);371 vrc = RTVfsFileRead(hVfsFile, pvFile, cbFile, NULL); 372 if (RT_FAILURE(vrc)) 373 pstrErr = &(new RTCString)->printf(ExtPackUtil::tr("RTVfsFileRead failed: %Rrc"), vrc); 374 374 375 375 /* … … 377 377 */ 378 378 xml::Document Doc; 379 if (RT_SUCCESS( rc))379 if (RT_SUCCESS(vrc)) 380 380 { 381 381 xml::XmlMemParser Parser; … … 388 388 { 389 389 pstrErr = new RTCString(rErr.what()); 390 rc = VERR_PARSE_ERROR;390 vrc = VERR_PARSE_ERROR; 391 391 } 392 392 } … … 396 396 * Hand the xml doc over to the common code. 397 397 */ 398 if (RT_SUCCESS( rc))398 if (RT_SUCCESS(vrc)) 399 399 try 400 400 { … … 650 650 { 651 651 /** @todo Should probably restrict this to known build types (alpha, 652 * beta, r c, ++). */652 * beta, release candidate, ++). */ 653 653 do 654 654 pszVersion++; … … 708 708 * RTStrPrintfv wrapper. 709 709 * 710 * @returns @a rc711 * @param rcThe status code to return.710 * @returns @a vrc 711 * @param vrc The status code to return. 712 712 * @param pszError The error buffer. 713 713 * @param cbError The size of the buffer. … … 715 715 * @param ... Format arguments. 716 716 */ 717 static int vboxExtPackReturnError(int rc, char *pszError, size_t cbError, const char *pszFormat, ...)717 static int vboxExtPackReturnError(int vrc, char *pszError, size_t cbError, const char *pszFormat, ...) 718 718 { 719 719 va_list va; … … 721 721 RTStrPrintfV(pszError, cbError, pszFormat, va); 722 722 va_end(va); 723 return rc;723 return vrc; 724 724 } 725 725 … … 769 769 /** @todo drop this restriction after the old install interface is 770 770 * dropped. */ 771 int rc = VINF_SUCCESS;771 int vrc = VINF_SUCCESS; 772 772 if ( pszExtPackName 773 773 && !ExtPackDesc.strName.equalsIgnoreCase(pszExtPackName)) 774 rc = vboxExtPackReturnError(VERR_NOT_EQUAL, pszError, cbError,775 ExtPackUtil::tr("The name of the downloaded file and the name stored inside the extension pack does not match"776 " (xml='%s' file='%s')"), ExtPackDesc.strName.c_str(), pszExtPackName);777 return rc;774 vrc = vboxExtPackReturnError(VERR_NOT_EQUAL, pszError, cbError, 775 ExtPackUtil::tr("The name of the downloaded file and the name stored inside the extension pack does not match" 776 " (xml='%s' file='%s')"), ExtPackDesc.strName.c_str(), pszExtPackName); 777 return vrc; 778 778 } 779 779 … … 794 794 * Read the manifest from the extension pack. 795 795 */ 796 int rc = RTVfsFileSeek(hManifestFile, 0, RTFILE_SEEK_BEGIN, NULL);797 if (RT_FAILURE( rc))798 return vboxExtPackReturnError( rc, pszError, cbError, ExtPackUtil::tr("RTVfsFileSeek failed: %Rrc"),rc);796 int vrc = RTVfsFileSeek(hManifestFile, 0, RTFILE_SEEK_BEGIN, NULL); 797 if (RT_FAILURE(vrc)) 798 return vboxExtPackReturnError(vrc, pszError, cbError, ExtPackUtil::tr("RTVfsFileSeek failed: %Rrc"), vrc); 799 799 800 800 RTMANIFEST hTheirManifest; 801 rc = RTManifestCreate(0 /*fFlags*/, &hTheirManifest);802 if (RT_FAILURE( rc))803 return vboxExtPackReturnError( rc, pszError, cbError, ExtPackUtil::tr("RTManifestCreate failed: %Rrc"),rc);801 vrc = RTManifestCreate(0 /*fFlags*/, &hTheirManifest); 802 if (RT_FAILURE(vrc)) 803 return vboxExtPackReturnError(vrc, pszError, cbError, ExtPackUtil::tr("RTManifestCreate failed: %Rrc"), vrc); 804 804 805 805 RTVFSIOSTREAM hVfsIos = RTVfsFileToIoStream(hManifestFile); 806 rc = RTManifestReadStandard(hTheirManifest, hVfsIos);806 vrc = RTManifestReadStandard(hTheirManifest, hVfsIos); 807 807 RTVfsIoStrmRelease(hVfsIos); 808 if (RT_SUCCESS( rc))808 if (RT_SUCCESS(vrc)) 809 809 { 810 810 /* … … 820 820 }; 821 821 char szError[RTPATH_MAX]; 822 rc = RTManifestEqualsEx(hOurManifest, hTheirManifest, &s_apszIgnoreEntries[0], NULL,823 RTMANIFEST_EQUALS_IGN_MISSING_ATTRS /*fFlags*/,824 szError, sizeof(szError));825 if (RT_SUCCESS( rc))822 vrc = RTManifestEqualsEx(hOurManifest, hTheirManifest, &s_apszIgnoreEntries[0], NULL, 823 RTMANIFEST_EQUALS_IGN_MISSING_ATTRS /*fFlags*/, 824 szError, sizeof(szError)); 825 if (RT_SUCCESS(vrc)) 826 826 { 827 827 /* … … 832 832 833 833 } 834 else if ( rc == VERR_NOT_EQUAL && szError[0])834 else if (vrc == VERR_NOT_EQUAL && szError[0]) 835 835 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Manifest mismatch: %s"), szError); 836 836 else 837 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestEqualsEx failed: %Rrc"), rc);837 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestEqualsEx failed: %Rrc"), vrc); 838 838 #if 0 839 839 RTVFSIOSTREAM hVfsIosStdOut = NIL_RTVFSIOSTREAM; … … 846 846 } 847 847 else 848 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Error parsing '%s': %Rrc"), VBOX_EXTPACK_MANIFEST_NAME, rc);848 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Error parsing '%s': %Rrc"), VBOX_EXTPACK_MANIFEST_NAME, vrc); 849 849 850 850 RTManifestRelease(hTheirManifest); 851 return rc;851 return vrc; 852 852 } 853 853 … … 871 871 */ 872 872 char szCalculatedDigest[RTSHA256_DIGEST_LEN + 1]; 873 int rc = RTManifestEntryQueryAttr(hFileManifest, "extpack", NULL /*no name*/, RTMANIFEST_ATTR_SHA256,874 szCalculatedDigest, sizeof(szCalculatedDigest), NULL);875 if (RT_SUCCESS( rc))873 int vrc = RTManifestEntryQueryAttr(hFileManifest, "extpack", NULL /*no name*/, RTMANIFEST_ATTR_SHA256, 874 szCalculatedDigest, sizeof(szCalculatedDigest), NULL); 875 if (RT_SUCCESS(vrc)) 876 876 { 877 877 /* … … 881 881 */ 882 882 uint8_t abCalculatedHash[RTSHA256_HASH_SIZE]; 883 rc = RTSha256FromString(szCalculatedDigest, abCalculatedHash);884 if (RT_SUCCESS( rc))883 vrc = RTSha256FromString(szCalculatedDigest, abCalculatedHash); 884 if (RT_SUCCESS(vrc)) 885 885 { 886 886 if ( pszFileDigest … … 888 888 { 889 889 uint8_t abFileHash[RTSHA256_HASH_SIZE]; 890 rc = RTSha256FromString(pszFileDigest, abFileHash);891 if (RT_SUCCESS( rc))890 vrc = RTSha256FromString(pszFileDigest, abFileHash); 891 if (RT_SUCCESS(vrc)) 892 892 { 893 893 if (memcmp(abFileHash, abCalculatedHash, sizeof(abFileHash))) … … 895 895 vboxExtPackSetError(pszError, cbError, 896 896 ExtPackUtil::tr("The extension pack file has changed (SHA-256 mismatch)")); 897 rc = VERR_NOT_EQUAL;897 vrc = VERR_NOT_EQUAL; 898 898 } 899 899 } 900 900 else 901 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Bad SHA-256 '%s': %Rrc"), szCalculatedDigest, rc);901 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Bad SHA-256 '%s': %Rrc"), szCalculatedDigest, vrc); 902 902 } 903 903 … … 905 905 * Set the output hash on success. 906 906 */ 907 if (pStrDigest && RT_SUCCESS( rc))907 if (pStrDigest && RT_SUCCESS(vrc)) 908 908 { 909 909 try … … 913 913 catch (std::bad_alloc &) 914 914 { 915 rc = VERR_NO_MEMORY;915 vrc = VERR_NO_MEMORY; 916 916 } 917 917 } 918 918 } 919 919 else 920 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Bad SHA-256 '%s': %Rrc"), szCalculatedDigest, rc);920 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("Bad SHA-256 '%s': %Rrc"), szCalculatedDigest, vrc); 921 921 } 922 922 else 923 vboxExtPackSetError(pszError, cbError, "RTManifestEntryGetAttr: %Rrc", rc);924 return rc;923 vboxExtPackSetError(pszError, cbError, "RTManifestEntryGetAttr: %Rrc", vrc); 924 return vrc; 925 925 } 926 926 … … 945 945 PRTVFSOBJ phVfsObj, PRTVFSFILE phVfsFile, char *pszError, size_t cbError) 946 946 { 947 int rc;947 int vrc; 948 948 949 949 /* … … 951 951 */ 952 952 if (phVfsFile && *phVfsFile != NIL_RTVFSFILE) 953 rc = vboxExtPackReturnError(VERR_DUPLICATE, pszError, cbError,954 ExtPackUtil::tr("There can only be one '%s'"), pszAdjName);953 vrc = vboxExtPackReturnError(VERR_DUPLICATE, pszError, cbError, 954 ExtPackUtil::tr("There can only be one '%s'"), pszAdjName); 955 955 else if (enmType != RTVFSOBJTYPE_IO_STREAM && enmType != RTVFSOBJTYPE_FILE) 956 rc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError,957 ExtPackUtil::tr("Standard member '%s' is not a file"), pszAdjName);956 vrc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError, 957 ExtPackUtil::tr("Standard member '%s' is not a file"), pszAdjName); 958 958 else 959 959 { 960 960 RTFSOBJINFO ObjInfo; 961 rc = RTVfsObjQueryInfo(*phVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING);962 if (RT_SUCCESS( rc))961 vrc = RTVfsObjQueryInfo(*phVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING); 962 if (RT_SUCCESS(vrc)) 963 963 { 964 964 if (!RTFS_IS_FILE(ObjInfo.Attr.fMode)) 965 rc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError,966 ExtPackUtil::tr("Standard member '%s' is not a file"), pszAdjName);965 vrc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError, 966 ExtPackUtil::tr("Standard member '%s' is not a file"), pszAdjName); 967 967 else if (ObjInfo.cbObject >= _1M) 968 rc = vboxExtPackReturnError(VERR_OUT_OF_RANGE, pszError, cbError,969 ExtPackUtil::tr("Standard member '%s' is too large: %'RU64 bytes (max 1 MB)", "",970 (size_t)ObjInfo.cbObject),971 pszAdjName, (uint64_t)ObjInfo.cbObject);968 vrc = vboxExtPackReturnError(VERR_OUT_OF_RANGE, pszError, cbError, 969 ExtPackUtil::tr("Standard member '%s' is too large: %'RU64 bytes (max 1 MB)", "", 970 (size_t)ObjInfo.cbObject), 971 pszAdjName, (uint64_t)ObjInfo.cbObject); 972 972 else 973 973 { … … 978 978 RTVFSIOSTREAM hVfsIos = RTVfsObjToIoStream(*phVfsObj); 979 979 RTVFSFILE hVfsFile; 980 rc = RTVfsMemorizeIoStreamAsFile(hVfsIos, RTFILE_O_READ, &hVfsFile);981 if (RT_SUCCESS( rc))980 vrc = RTVfsMemorizeIoStreamAsFile(hVfsIos, RTFILE_O_READ, &hVfsFile); 981 if (RT_SUCCESS(vrc)) 982 982 { 983 rc = RTVfsIoStrmValidateUtf8Encoding(hVfsIos,984 RTVFS_VALIDATE_UTF8_BY_RTC_3629 | RTVFS_VALIDATE_UTF8_NO_NULL,985 NULL);986 if (RT_SUCCESS( rc))983 vrc = RTVfsIoStrmValidateUtf8Encoding(hVfsIos, 984 RTVFS_VALIDATE_UTF8_BY_RTC_3629 | RTVFS_VALIDATE_UTF8_NO_NULL, 985 NULL); 986 if (RT_SUCCESS(vrc)) 987 987 { 988 988 /* 989 989 * Replace *phVfsObj with the memorized file. 990 990 */ 991 rc = RTVfsFileSeek(hVfsFile, 0, RTFILE_SEEK_BEGIN, NULL);992 if (RT_SUCCESS( rc))991 vrc = RTVfsFileSeek(hVfsFile, 0, RTFILE_SEEK_BEGIN, NULL); 992 if (RT_SUCCESS(vrc)) 993 993 { 994 994 RTVfsObjRelease(*phVfsObj); … … 997 997 else 998 998 vboxExtPackSetError(pszError, cbError, 999 ExtPackUtil::tr("RTVfsFileSeek failed on '%s': %Rrc"), pszAdjName, rc);999 ExtPackUtil::tr("RTVfsFileSeek failed on '%s': %Rrc"), pszAdjName, vrc); 1000 1000 } 1001 1001 1002 if (phVfsFile && RT_SUCCESS( rc))1002 if (phVfsFile && RT_SUCCESS(vrc)) 1003 1003 *phVfsFile = hVfsFile; 1004 1004 else … … 1007 1007 else 1008 1008 vboxExtPackSetError(pszError, cbError, 1009 ExtPackUtil::tr("RTVfsMemorizeIoStreamAsFile failed on '%s': %Rrc"), pszAdjName, rc);1009 ExtPackUtil::tr("RTVfsMemorizeIoStreamAsFile failed on '%s': %Rrc"), pszAdjName, vrc); 1010 1010 RTVfsIoStrmRelease(hVfsIos); 1011 1011 } 1012 1012 } 1013 1013 else 1014 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszAdjName, rc);1015 } 1016 return rc;1014 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszAdjName, vrc); 1015 } 1016 return vrc; 1017 1017 } 1018 1018 … … 1100 1100 static int vboxExtPackValidateMemberFile(const char *pszName, RTVFSOBJ hVfsObj, char *pszError, size_t cbError) 1101 1101 { 1102 int rc = vboxExtPackValidateMemberName(pszName, pszError, cbError);1103 if (RT_SUCCESS( rc))1102 int vrc = vboxExtPackValidateMemberName(pszName, pszError, cbError); 1103 if (RT_SUCCESS(vrc)) 1104 1104 { 1105 1105 RTFSOBJINFO ObjInfo; 1106 rc = RTVfsObjQueryInfo(hVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING);1107 if (RT_SUCCESS( rc))1106 vrc = RTVfsObjQueryInfo(hVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING); 1107 if (RT_SUCCESS(vrc)) 1108 1108 { 1109 1109 if (ObjInfo.cbObject >= 9*_1G64) 1110 rc = vboxExtPackReturnError(VERR_OUT_OF_RANGE, pszError, cbError,1111 ExtPackUtil::tr("'%s': too large (%'RU64 bytes)", "", (size_t)ObjInfo.cbObject),1112 pszName, (uint64_t)ObjInfo.cbObject);1110 vrc = vboxExtPackReturnError(VERR_OUT_OF_RANGE, pszError, cbError, 1111 ExtPackUtil::tr("'%s': too large (%'RU64 bytes)", "", (size_t)ObjInfo.cbObject), 1112 pszName, (uint64_t)ObjInfo.cbObject); 1113 1113 if (!RTFS_IS_FILE(ObjInfo.Attr.fMode)) 1114 rc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError,1115 ExtPackUtil::tr("The alleged file '%s' has a mode mask stating otherwise (%RTfmode)"),1116 pszName, ObjInfo.Attr.fMode);1114 vrc = vboxExtPackReturnError(VERR_NOT_A_FILE, pszError, cbError, 1115 ExtPackUtil::tr("The alleged file '%s' has a mode mask stating otherwise (%RTfmode)"), 1116 pszName, ObjInfo.Attr.fMode); 1117 1117 } 1118 1118 else 1119 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszName, rc);1120 } 1121 return rc;1119 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszName, vrc); 1120 } 1121 return vrc; 1122 1122 } 1123 1123 … … 1134 1134 static int vboxExtPackValidateMemberDir(const char *pszName, RTVFSOBJ hVfsObj, char *pszError, size_t cbError) 1135 1135 { 1136 int rc = vboxExtPackValidateMemberName(pszName, pszError, cbError);1137 if (RT_SUCCESS( rc))1136 int vrc = vboxExtPackValidateMemberName(pszName, pszError, cbError); 1137 if (RT_SUCCESS(vrc)) 1138 1138 { 1139 1139 RTFSOBJINFO ObjInfo; 1140 rc = RTVfsObjQueryInfo(hVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING);1141 if (RT_SUCCESS( rc))1140 vrc = RTVfsObjQueryInfo(hVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING); 1141 if (RT_SUCCESS(vrc)) 1142 1142 { 1143 1143 if (!RTFS_IS_DIRECTORY(ObjInfo.Attr.fMode)) 1144 rc = vboxExtPackReturnError(VERR_NOT_A_DIRECTORY, pszError, cbError,1145 ExtPackUtil::tr("The alleged directory '%s' has a mode mask saying differently (%RTfmode)"),1146 pszName, ObjInfo.Attr.fMode);1144 vrc = vboxExtPackReturnError(VERR_NOT_A_DIRECTORY, pszError, cbError, 1145 ExtPackUtil::tr("The alleged directory '%s' has a mode mask saying differently (%RTfmode)"), 1146 pszName, ObjInfo.Attr.fMode); 1147 1147 } 1148 1148 else 1149 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszName, rc);1150 } 1151 return rc;1149 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsObjQueryInfo failed on '%s': %Rrc"), pszName, vrc); 1150 } 1151 return vrc; 1152 1152 } 1153 1153 … … 1167 1167 *pszError = '\0'; 1168 1168 1169 int rc;1169 int vrc; 1170 1170 if ( enmType == RTVFSOBJTYPE_FILE 1171 1171 || enmType == RTVFSOBJTYPE_IO_STREAM) 1172 rc = vboxExtPackValidateMemberFile(pszName, hVfsObj, pszError, cbError);1172 vrc = vboxExtPackValidateMemberFile(pszName, hVfsObj, pszError, cbError); 1173 1173 else if ( enmType == RTVFSOBJTYPE_DIR 1174 1174 || enmType == RTVFSOBJTYPE_BASE) 1175 rc = vboxExtPackValidateMemberDir(pszName, hVfsObj, pszError, cbError);1175 vrc = vboxExtPackValidateMemberDir(pszName, hVfsObj, pszError, cbError); 1176 1176 else 1177 rc = vboxExtPackReturnError(VERR_UNEXPECTED_FS_OBJ_TYPE, pszError, cbError,1178 ExtPackUtil::tr("'%s' is not a file or directory (enmType=%d)"), pszName, enmType);1179 return rc;1177 vrc = vboxExtPackReturnError(VERR_UNEXPECTED_FS_OBJ_TYPE, pszError, cbError, 1178 ExtPackUtil::tr("'%s' is not a file or directory (enmType=%d)"), pszName, enmType); 1179 return vrc; 1180 1180 } 1181 1181 … … 1205 1205 * Rewind the file and set up a VFS chain for it. 1206 1206 */ 1207 int rc = RTFileSeek(hTarballFile, 0, RTFILE_SEEK_BEGIN, NULL);1208 if (RT_FAILURE( rc))1209 return vboxExtPackReturnError( rc, pszError, cbError,1210 ExtPackUtil::tr("Failed seeking to the start of the tarball: %Rrc"), rc);1207 int vrc = RTFileSeek(hTarballFile, 0, RTFILE_SEEK_BEGIN, NULL); 1208 if (RT_FAILURE(vrc)) 1209 return vboxExtPackReturnError(vrc, pszError, cbError, 1210 ExtPackUtil::tr("Failed seeking to the start of the tarball: %Rrc"), vrc); 1211 1211 1212 1212 RTVFSIOSTREAM hTarballIos; 1213 rc = RTVfsIoStrmFromRTFile(hTarballFile, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN, true /*fLeaveOpen*/,1214 &hTarballIos);1215 if (RT_FAILURE( rc))1216 return vboxExtPackReturnError( rc, pszError, cbError, ExtPackUtil::tr("RTVfsIoStrmFromRTFile failed: %Rrc"),rc);1213 vrc = RTVfsIoStrmFromRTFile(hTarballFile, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN, true /*fLeaveOpen*/, 1214 &hTarballIos); 1215 if (RT_FAILURE(vrc)) 1216 return vboxExtPackReturnError(vrc, pszError, cbError, ExtPackUtil::tr("RTVfsIoStrmFromRTFile failed: %Rrc"), vrc); 1217 1217 1218 1218 RTMANIFEST hFileManifest = NIL_RTMANIFEST; 1219 rc = RTManifestCreate(0 /*fFlags*/, &hFileManifest);1220 if (RT_SUCCESS( rc))1219 vrc = RTManifestCreate(0 /*fFlags*/, &hFileManifest); 1220 if (RT_SUCCESS(vrc)) 1221 1221 { 1222 1222 RTVFSIOSTREAM hPtIos; 1223 rc = RTManifestEntryAddPassthruIoStream(hFileManifest, hTarballIos, "extpack", RTMANIFEST_ATTR_SHA256,1224 true /*read*/, &hPtIos);1225 if (RT_SUCCESS( rc))1223 vrc = RTManifestEntryAddPassthruIoStream(hFileManifest, hTarballIos, "extpack", RTMANIFEST_ATTR_SHA256, 1224 true /*read*/, &hPtIos); 1225 if (RT_SUCCESS(vrc)) 1226 1226 { 1227 1227 RTVFSIOSTREAM hGunzipIos; 1228 rc = RTZipGzipDecompressIoStream(hPtIos, 0 /*fFlags*/, &hGunzipIos);1229 if (RT_SUCCESS( rc))1228 vrc = RTZipGzipDecompressIoStream(hPtIos, 0 /*fFlags*/, &hGunzipIos); 1229 if (RT_SUCCESS(vrc)) 1230 1230 { 1231 1231 RTVFSFSSTREAM hTarFss; 1232 rc = RTZipTarFsStreamFromIoStream(hGunzipIos, 0 /*fFlags*/, &hTarFss);1233 if (RT_SUCCESS( rc))1232 vrc = RTZipTarFsStreamFromIoStream(hGunzipIos, 0 /*fFlags*/, &hTarFss); 1233 if (RT_SUCCESS(vrc)) 1234 1234 { 1235 1235 RTVfsIoStrmRelease(hPtIos); … … 1244 1244 } 1245 1245 1246 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipTarFsStreamFromIoStream failed: %Rrc"), rc);1246 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipTarFsStreamFromIoStream failed: %Rrc"), vrc); 1247 1247 RTVfsIoStrmRelease(hGunzipIos); 1248 1248 } 1249 1249 else 1250 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipGzipDecompressIoStream failed: %Rrc"), rc);1250 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipGzipDecompressIoStream failed: %Rrc"), vrc); 1251 1251 RTVfsIoStrmRelease(hPtIos); 1252 1252 } 1253 1253 else 1254 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestEntryAddPassthruIoStream failed: %Rrc"), rc);1254 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestEntryAddPassthruIoStream failed: %Rrc"), vrc); 1255 1255 RTManifestRelease(hFileManifest); 1256 1256 } 1257 1257 else 1258 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestCreate failed: %Rrc"), rc);1258 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTManifestCreate failed: %Rrc"), vrc); 1259 1259 1260 1260 RTVfsIoStrmRelease(hTarballIos); 1261 return rc;1261 return vrc; 1262 1262 } 1263 1263 … … 1311 1311 RTMANIFEST hFileManifest; 1312 1312 RTVFSFSSTREAM hTarFss; 1313 int rc = VBoxExtPackOpenTarFss(hTarballFile, pszError, cbError, &hTarFss, &hFileManifest);1314 if (RT_FAILURE( rc))1315 return rc;1313 int vrc = VBoxExtPackOpenTarFss(hTarballFile, pszError, cbError, &hTarFss, &hFileManifest); 1314 if (RT_FAILURE(vrc)) 1315 return vrc; 1316 1316 1317 1317 RTMANIFEST hOurManifest; 1318 rc = RTManifestCreate(0 /*fFlags*/, &hOurManifest);1319 if (RT_SUCCESS( rc))1318 vrc = RTManifestCreate(0 /*fFlags*/, &hOurManifest); 1319 if (RT_SUCCESS(vrc)) 1320 1320 { 1321 1321 /* … … 1333 1333 RTVFSOBJ hVfsObj; 1334 1334 RTVFSOBJTYPE enmType; 1335 rc = RTVfsFsStrmNext(hTarFss, &pszName, &enmType, &hVfsObj);1336 if (RT_FAILURE( rc))1335 vrc = RTVfsFsStrmNext(hTarFss, &pszName, &enmType, &hVfsObj); 1336 if (RT_FAILURE(vrc)) 1337 1337 { 1338 if ( rc != VERR_EOF)1339 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsFsStrmNext failed: %Rrc"), rc);1338 if (vrc != VERR_EOF) 1339 vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTVfsFsStrmNext failed: %Rrc"), vrc); 1340 1340 else 1341 rc = VINF_SUCCESS;1341 vrc = VINF_SUCCESS; 1342 1342 break; 1343 1343 } … … 1351 1351 * failure - cleanup reasons. 1352 1352 */ 1353 rc = VBoxExtPackValidateMember(pszName, enmType, hVfsObj, pszError, cbError);1354 if (RT_SUCCESS( rc))1353 vrc = VBoxExtPackValidateMember(pszName, enmType, hVfsObj, pszError, cbError); 1354 if (RT_SUCCESS(vrc)) 1355 1355 { 1356 1356 PRTVFSFILE phVfsFile = NULL; … … 1362 1362 phVfsFile = &hSignatureFile; 1363 1363 else if (!strncmp(pszAdjName, VBOX_EXTPACK_LICENSE_NAME_PREFIX, sizeof(VBOX_EXTPACK_LICENSE_NAME_PREFIX) - 1)) 1364 rc = VBoxExtPackValidateStandardFile(pszAdjName, enmType, &hVfsObj, NULL, pszError, cbError);1364 vrc = VBoxExtPackValidateStandardFile(pszAdjName, enmType, &hVfsObj, NULL, pszError, cbError); 1365 1365 if (phVfsFile) 1366 rc = VBoxExtPackValidateStandardFile(pszAdjName, enmType, &hVfsObj, phVfsFile, pszError, cbError);1366 vrc = VBoxExtPackValidateStandardFile(pszAdjName, enmType, &hVfsObj, phVfsFile, pszError, cbError); 1367 1367 } 1368 1368 … … 1370 1370 * Add any I/O stream to the manifest 1371 1371 */ 1372 if ( RT_SUCCESS( rc)1372 if ( RT_SUCCESS(vrc) 1373 1373 && ( enmType == RTVFSOBJTYPE_FILE 1374 1374 || enmType == RTVFSOBJTYPE_IO_STREAM)) 1375 1375 { 1376 1376 RTVFSIOSTREAM hVfsIos = RTVfsObjToIoStream(hVfsObj); 1377 rc = RTManifestEntryAddIoStream(hOurManifest, hVfsIos, pszAdjName, RTMANIFEST_ATTR_SIZE | RTMANIFEST_ATTR_SHA256);1378 if (RT_FAILURE( rc))1377 vrc = RTManifestEntryAddIoStream(hOurManifest, hVfsIos, pszAdjName, RTMANIFEST_ATTR_SIZE | RTMANIFEST_ATTR_SHA256); 1378 if (RT_FAILURE(vrc)) 1379 1379 vboxExtPackSetError(pszError, cbError, 1380 ExtPackUtil::tr("RTManifestEntryAddIoStream failed on '%s': %Rrc"), pszAdjName, rc);1380 ExtPackUtil::tr("RTManifestEntryAddIoStream failed on '%s': %Rrc"), pszAdjName, vrc); 1381 1381 RTVfsIoStrmRelease(hVfsIos); 1382 1382 } … … 1387 1387 RTVfsObjRelease(hVfsObj); 1388 1388 RTStrFree(pszName); 1389 if (RT_FAILURE( rc))1389 if (RT_FAILURE(vrc)) 1390 1390 break; 1391 1391 } … … 1394 1394 * Check the integrity of the tarball file. 1395 1395 */ 1396 if (RT_SUCCESS( rc))1396 if (RT_SUCCESS(vrc)) 1397 1397 { 1398 1398 RTVfsFsStrmRelease(hTarFss); 1399 1399 hTarFss = NIL_RTVFSFSSTREAM; 1400 rc = vboxExtPackVerifyFileDigest(hFileManifest, pszTarballDigest, pStrDigest, pszError, cbError);1400 vrc = vboxExtPackVerifyFileDigest(hFileManifest, pszTarballDigest, pStrDigest, pszError, cbError); 1401 1401 } 1402 1402 … … 1405 1405 * mandatory files are present. 1406 1406 */ 1407 if (RT_SUCCESS( rc))1407 if (RT_SUCCESS(vrc)) 1408 1408 { 1409 1409 if (hXmlFile == NIL_RTVFSFILE) 1410 rc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"),1411 VBOX_EXTPACK_DESCRIPTION_NAME);1410 vrc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"), 1411 VBOX_EXTPACK_DESCRIPTION_NAME); 1412 1412 if (hManifestFile == NIL_RTVFSFILE) 1413 rc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"),1414 VBOX_EXTPACK_MANIFEST_NAME);1413 vrc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"), 1414 VBOX_EXTPACK_MANIFEST_NAME); 1415 1415 if (hSignatureFile == NIL_RTVFSFILE) 1416 rc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"),1417 VBOX_EXTPACK_SIGNATURE_NAME);1416 vrc = vboxExtPackReturnError(VERR_MISSING, pszError, cbError, ExtPackUtil::tr("Mandator file '%s' is missing"), 1417 VBOX_EXTPACK_SIGNATURE_NAME); 1418 1418 } 1419 1419 … … 1421 1421 * Check the manifest and it's signature. 1422 1422 */ 1423 if (RT_SUCCESS( rc))1424 rc = vboxExtPackVerifyManifestAndSignature(hOurManifest, hManifestFile, hSignatureFile, pszError, cbError);1423 if (RT_SUCCESS(vrc)) 1424 vrc = vboxExtPackVerifyManifestAndSignature(hOurManifest, hManifestFile, hSignatureFile, pszError, cbError); 1425 1425 1426 1426 /* 1427 1427 * Check the XML. 1428 1428 */ 1429 if (RT_SUCCESS( rc))1430 rc = vboxExtPackVerifyXml(hXmlFile, pszExtPackName, pszError, cbError);1429 if (RT_SUCCESS(vrc)) 1430 vrc = vboxExtPackVerifyXml(hXmlFile, pszExtPackName, pszError, cbError); 1431 1431 1432 1432 /* 1433 1433 * Returns objects. 1434 1434 */ 1435 if (RT_SUCCESS( rc))1435 if (RT_SUCCESS(vrc)) 1436 1436 { 1437 1437 if (phValidManifest) … … 1456 1456 } 1457 1457 else 1458 vboxExtPackSetError(pszError, cbError, "RTManifestCreate failed: %Rrc", rc);1458 vboxExtPackSetError(pszError, cbError, "RTManifestCreate failed: %Rrc", vrc); 1459 1459 RTVfsFsStrmRelease(hTarFss); 1460 1460 RTManifestRelease(hFileManifest); 1461 1461 1462 return rc;1463 } 1464 1462 return vrc; 1463 } 1464
Note:
See TracChangeset
for help on using the changeset viewer.