1 /* 2 Copyright (c) 2023 Intel Corporation 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 //! \file test_fuzzing.cpp 18 //! \brief Test the fuzzing of environment variables 19 20 #include <fuzzer/FuzzedDataProvider.h> 21 22 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 23 FuzzedDataProvider provider(data, size); 24 for (auto var : {"INTEL_ITTNOTIFY_GROUPS", "INTEL_LIBITTNOTIFY32", 25 "INTEL_LIBITTNOTIFY64", "KMP_FOR_TCHECK", "KMP_FOR_TPROFILE", 26 "TBB_ENABLE_SANITIZERS", "TBB_MALLOC_DISABLE_REPLACEMENT", 27 "TBB_MALLOC_SET_HUGE_SIZE_THRESHOLD", 28 "TBB_MALLOC_USE_HUGE_PAGES", "TBB_VERSION"}) { 29 std::string val = provider.ConsumeRandomLengthString(); 30 #if _WIN32 31 _putenv_s(var, val.c_str()); 32 #else 33 setenv(var, val.c_str(), 1); 34 #endif 35 } 36 37 if (std::system(CMD) != 0) 38 __builtin_trap(); 39 40 return 0; 41 } 42