Skip to content

Commit fb1133e

Browse files
authored
Prevent timeout fault running DOMConfiguratorFuzzer (#482)
1 parent c866dfc commit fb1133e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "stdint.h"
1918
#include <fuzzer/FuzzedDataProvider.h>
2019
#include <log4cxx/xml/domconfigurator.h>
2120

21+
namespace
22+
{
23+
const size_t MaximumFileByteCount = 100000;
24+
}
25+
2226
using namespace log4cxx;
2327
using namespace log4cxx::helpers;
2428
using namespace log4cxx::xml;
@@ -30,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
3034
if (!fp) {
3135
return 0;
3236
}
33-
fwrite(data, size, 1, fp);
37+
fwrite(data, std::min(size, MaximumFileByteCount), 1, fp);
3438
fclose(fp);
3539
DOMConfigurator::configure(filename);
3640
return 0;

0 commit comments

Comments
 (0)