MCPcopy Create free account
hub / github.com/OSGeo/gdal / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

fuzzers/gdal_algorithm_fuzzer.cpp:50–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
51{
52 VSILFILE *fp = VSIFileFromMemBuffer(
53 "/vsimem/test.tar",
54 reinterpret_cast<GByte *>(const_cast<uint8_t *>(buf)), len, FALSE);
55 VSIFCloseL(fp);
56
57 CPLPushErrorHandler(CPLQuietErrorHandler);
58
59 auto &singleton = GDALGlobalAlgorithmRegistry::GetSingleton();
60 std::unique_ptr<GDALAlgorithm> alg;
61
62 fp = VSIFOpenL("/vsitar//vsimem/test.tar/cmd.txt", "rb");
63 if (fp != nullptr)
64 {
65 const char *pszLine = nullptr;
66 if ((pszLine = CPLReadLineL(fp)) != nullptr)
67 {
68 alg = singleton.Instantiate(pszLine);
69 }
70 if (alg)
71 {
72 while ((pszLine = CPLReadLineL(fp)) != nullptr)
73 {
74 auto subalg = alg->InstantiateSubAlgorithm(pszLine);
75 if (subalg)
76 alg = std::move(subalg);
77 else
78 break;
79 }
80 }
81 if (alg && pszLine)
82 {
83 GDALAlgorithmArg *arg = nullptr;
84 do
85 {
86 if (!arg)
87 {
88 arg = alg->GetArg(pszLine);
89 if (!arg)
90 break;
91 if (arg->GetType() == GAAT_BOOLEAN)
92 {
93 arg->Set(true);
94 arg = nullptr;
95 }
96 }
97 else
98 {
99 try
100 {
101 arg->Set(pszLine);
102 }
103 catch (const std::exception &)
104 {
105 }
106 arg = nullptr;
107 }

Callers

nothing calls this directly

Calls 15

VSIFileFromMemBufferFunction · 0.85
VSIFCloseLFunction · 0.85
VSIFOpenLFunction · 0.85
CPLReadLineLFunction · 0.85
moveFunction · 0.85
VSIRmdirRecursiveFunction · 0.85
InstantiateMethod · 0.80
GetArgMethod · 0.80
GetLayersMethod · 0.80
minFunction · 0.50
GetTypeMethod · 0.45

Tested by

no test coverage detected