| 48 | } |
| 49 | |
| 50 | int 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 | } |
nothing calls this directly
no test coverage detected