VirtualBox

Ignore:
Timestamp:
Feb 19, 2024 10:24:09 AM (9 months ago)
Author:
vboxsync
Message:

FsPerf: Reverted changes from r161579 again as these are unnecessary - there should be no risk of buffer overflows (see FSPERF_MAX_NEEDED_PATH) and they are inconsistent (continues testing after a path buffer overflow). Besides RTStrCat(RTStrCpy2(...)..) is unsafe and the whole change does not improve the code. bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/fs/FsPerf.cpp

    r103418 r103423  
    9999*   Defined Constants And Macros                                                                                                 *
    100100*********************************************************************************************************************************/
    101 /** Used for cutting the the -d parameter value short and avoid a number of buffer overflow checks.  */
     101/** Used for cutting the -d parameter value short and avoid a number of buffer overflow checks.  */
    102102#define FSPERF_MAX_NEEDED_PATH  224
    103103/** The max path used by this code.
     
    29542954{
    29552955    char szRenamed[FSPERF_MAX_PATH];
    2956     RTTESTI_CHECK_RC_OK(RTStrCat(RTStrCopy2(szRenamed, sizeof(szRenamed), pszFile), sizeof(szRenamed), "-renamed"));
     2956    strcat(strcpy(szRenamed, pszFile), "-renamed");
    29572957    if (!(iIteration & 1))
    29582958        return RTPathRename(pszFile, szRenamed, 0);
     
    29712971
    29722972    /* Non-existing files. */
    2973     RTTESTI_CHECK_RC_OK(RTStrCopy(szPath, sizeof(szPath), InEmptyDir(RT_STR_TUPLE("other-no-such-file"))));
     2973    strcpy(szPath, InEmptyDir(RT_STR_TUPLE("other-no-such-file")));
    29742974    RTTESTI_CHECK_RC(RTPathRename(InEmptyDir(RT_STR_TUPLE("no-such-file")), szPath, 0), VERR_FILE_NOT_FOUND);
    2975 
    2976     RTTESTI_CHECK_RC_OK(RTStrCopy(szPath, sizeof(szPath), InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "other-no-such-file"))));
     2975    strcpy(szPath, InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "other-no-such-file")));
    29772976    RTTESTI_CHECK_RC(RTPathRename(InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file")), szPath, 0),
    29782977                     FSPERF_VERR_PATH_NOT_FOUND);
    2979 
    2980     RTTESTI_CHECK_RC_OK(RTStrCopy(szPath, sizeof(szPath), InEmptyDir(RT_STR_TUPLE("other-no-such-file"))));
     2978    strcpy(szPath, InEmptyDir(RT_STR_TUPLE("other-no-such-file")));
    29812979    RTTESTI_CHECK_RC(RTPathRename(InDir(RT_STR_TUPLE("known-file" RTPATH_SLASH_STR "no-such-file")), szPath, 0), VERR_PATH_NOT_FOUND);
    29822980
     
    29852983                                     RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE | RTFILE_O_WRITE), VINF_SUCCESS);
    29862984    RTTESTI_CHECK_RC(RTFileClose(hFile1), VINF_SUCCESS);
    2987     RTTESTI_CHECK_RC_OK(RTStrCat(RTStrCopy2(szPath, sizeof(szPath), g_szDir), sizeof(szPath), "-no-such-dir" RTPATH_SLASH_STR "file16"));
     2985    strcat(strcpy(szPath, g_szDir), "-no-such-dir" RTPATH_SLASH_STR "file16");
    29882986    RTTESTI_CHECK_RC(RTPathRename(szPath, g_szDir, 0), FSPERF_VERR_PATH_NOT_FOUND);
    29892987    RTTESTI_CHECK_RC(RTPathRename(g_szDir, szPath, 0), FSPERF_VERR_PATH_NOT_FOUND);
    29902988
    29912989    /* Shallow: */
    2992     RTTESTI_CHECK_RC_OK(RTStrCat(RTStrCopy2(szPath, sizeof(szPath), g_szDir), sizeof(szPath), "-other"));
     2990    strcat(strcpy(szPath, g_szDir), "-other");
    29932991    PROFILE_FN(RTPathRename(iIteration & 1 ? szPath : g_szDir, iIteration & 1 ? g_szDir : szPath, 0), g_nsTestRun, "RTPathRename");
    29942992
     
    29982996    RTTESTI_CHECK_RC(RTFileClose(hFile1), VINF_SUCCESS);
    29992997
    3000     RTTESTI_CHECK_RC_OK(RTStrCat(RTStrCopy2(szPath, sizeof(szPath), g_szDeepDir), sizeof(szPath), "-other"));
     2998    strcat(strcpy(szPath, g_szDeepDir), "-other");
    30012999    PROFILE_FN(RTPathRename(iIteration & 1 ? szPath : g_szDeepDir, iIteration & 1 ? g_szDeepDir : szPath, 0),
    30023000               g_nsTestRun, "RTPathRename/deep");
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