VirtualBox

Changeset 83426 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Mar 25, 2020 7:40:09 PM (5 years ago)
Author:
vboxsync
Message:

Runtime/RTFuzzCfg: Initial implementation of API for configuring a fuzzing context. The config and input corpus is stored in a single tarball to keep things easy to pass around

Location:
trunk/src/VBox/Runtime
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r83124 r83426  
    21602160        common/checksum/crc32-zlib.cpp \
    21612161        common/fuzz/fuzz.cpp \
     2162        common/fuzz/fuzz-config.cpp \
    21622163        common/fuzz/fuzz-observer.cpp \
    21632164        common/fuzz/fuzz-target-recorder.cpp \
  • trunk/src/VBox/Runtime/common/fuzz/fuzz.cpp

    r83291 r83426  
    19291929
    19301930
     1931RTDECL(int) RTFuzzCtxCorpusInputAddFromVfsIoStrm(RTFUZZCTX hFuzzCtx, RTVFSIOSTREAM hVfsIos)
     1932{
     1933    PRTFUZZCTXINT pThis = hFuzzCtx;
     1934    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     1935    AssertReturn(hVfsIos != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
     1936
     1937    return RTFuzzCtxCorpusInputAddFromVfsIoStrmEx(hFuzzCtx, hVfsIos, pThis->offMutStart, pThis->cbMutRange);
     1938}
     1939
     1940RTDECL(int) RTFuzzCtxCorpusInputAddFromVfsIoStrmEx(RTFUZZCTX hFuzzCtx, RTVFSIOSTREAM hVfsIos,
     1941                                                   uint64_t offMutStart, uint64_t cbMutRange)
     1942{
     1943    PRTFUZZCTXINT pThis = hFuzzCtx;
     1944    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     1945    AssertReturn(hVfsIos != NIL_RTVFSIOSTREAM, VERR_INVALID_HANDLE);
     1946
     1947    void *pvCorpus = NULL;
     1948    RTFSOBJINFO ObjInfo;
     1949    int rc = RTVfsIoStrmQueryInfo(hVfsIos, &ObjInfo, RTFSOBJATTRADD_UNIX);
     1950    if (RT_SUCCESS(rc))
     1951    {
     1952        PRTFUZZMUTATION pMutation = rtFuzzMutationCreateEx(pThis, 0, NULL, offMutStart, cbMutRange,
     1953                                                           ObjInfo.cbObject, &pvCorpus);
     1954        if (RT_LIKELY(pMutation))
     1955        {
     1956            pMutation->pMutator = &g_MutatorCorpus;
     1957            pMutation->cbInput  = ObjInfo.cbObject;
     1958            pMutation->pvInput  = pvCorpus;
     1959            rc = RTVfsIoStrmRead(hVfsIos, pvCorpus, ObjInfo.cbObject, true /*fBlocking*/, NULL);
     1960            if (RT_SUCCESS(rc))
     1961                rc = rtFuzzCtxMutationAdd(pThis, pMutation);
     1962
     1963            if (RT_FAILURE(rc))
     1964                rtFuzzMutationDestroy(pMutation);
     1965        }
     1966        else
     1967            rc = VERR_NO_MEMORY;
     1968    }
     1969
     1970    return rc;
     1971}
     1972
     1973
    19311974RTDECL(int) RTFuzzCtxCorpusInputAddFromDirPath(RTFUZZCTX hFuzzCtx, const char *pszDirPath)
    19321975{
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