Changeset 103439 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Feb 19, 2024 1:43:33 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/xml.cpp
r103285 r103439 2306 2306 2307 2307 /* Construct both filenames first to ease error handling. */ 2308 size_t const cchFilename = strlen(pcszFilename); 2309 size_t const cchTmpSuff = strlen(s_pszTmpSuff); 2310 size_t const cchPrevSuff = strlen(s_pszPrevSuff); 2311 AssertStmt(cchFilename + RT_MAX(cchTmpSuff, cchPrevSuff) < RTPATH_MAX, 2312 throw EIPRTFailure(VERR_BUFFER_OVERFLOW, "filename to long (%zu)", cchFilename)); 2313 2308 2314 char szTmpFilename[RTPATH_MAX]; 2309 int rc = RTStrCopy(szTmpFilename, sizeof(szTmpFilename) - strlen(s_pszTmpSuff), pcszFilename); 2310 if (RT_FAILURE(rc)) 2311 throw EIPRTFailure(rc, "RTStrCopy"); 2312 rc = RTStrCat(szTmpFilename, sizeof(szTmpFilename), s_pszTmpSuff); 2313 if (RT_FAILURE(rc)) 2314 throw EIPRTFailure(rc, "RTStrCat"); 2315 memcpy(mempcpy(szTmpFilename, pcszFilename, cchFilename), s_pszTmpSuff, cchTmpSuff + 1); 2315 2316 2316 2317 char szPrevFilename[RTPATH_MAX]; 2317 rc = RTStrCopy(szPrevFilename, sizeof(szPrevFilename) - strlen(s_pszPrevSuff), pcszFilename); 2318 if (RT_FAILURE(rc)) 2319 throw EIPRTFailure(rc, "RTStrCopy"); 2320 strcat(szPrevFilename, s_pszPrevSuff); 2318 memcpy(mempcpy(szPrevFilename, pcszFilename, cchFilename), s_pszPrevSuff, cchPrevSuff + 1); 2321 2319 2322 2320 /* Write the XML document to the temporary file. */ … … 2325 2323 /* Make a backup of any existing file (ignore failure). */ 2326 2324 uint64_t cbPrevFile; 2327 rc = RTFileQuerySizeByPath(pcszFilename, &cbPrevFile);2325 int rc = RTFileQuerySizeByPath(pcszFilename, &cbPrevFile); 2328 2326 if (RT_SUCCESS(rc) && cbPrevFile >= 16) 2329 2327 RTFileRename(pcszFilename, szPrevFilename, RTPATHRENAME_FLAGS_REPLACE);
Note:
See TracChangeset
for help on using the changeset viewer.