[expat] working build & simple fuzzer from chrome.

This commit is contained in:
Mike Aizatsky 2016-07-26 13:59:42 -07:00
parent e0b3abddf8
commit d3df019019
3 changed files with 32 additions and 3 deletions

View File

@ -16,5 +16,6 @@
FROM ossfuzz/base-libfuzzer
MAINTAINER mike.aizatsky@gmail.com
RUN apt-get install -y autoconf automake libtool
CMD /workspace/oss-fuzz/expat/build.sh
CMD /src/oss-fuzz/expat/build.sh

View File

@ -1,8 +1,13 @@
#!/bin/bash -ex
. /env
echo $pwd
cd /workspace/expat
ls -alR
./buildconf.sh
./configure
make clean all
$CXX $CXXFLAGS -std=c++11 -Ilib/ \
/src/oss-fuzz/expat/parse_fuzzer.cc -o /out/parse_fuzzer \
/work/libfuzzer/*.o .libs/libexpat.a

23
expat/parse_fuzzer.cc Normal file
View File

@ -0,0 +1,23 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "expat.h"
std::vector<const char*> kEncodings = {{"UTF-16", "UTF-8", "ISO-8859-1",
"US-ASCII", "UTF-16BE", "UTF-16LE",
"INVALIDENCODING"}};
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
const char* dataPtr = reinterpret_cast<const char*>(data);
for (int use_ns = 0; use_ns <= 1; ++use_ns) {
for (auto enc : kEncodings) {
XML_Parser parser =
use_ns ? XML_ParserCreateNS(enc, '\n') : XML_ParserCreate(enc);
XML_Parse(parser, dataPtr, size, true);
XML_ParserFree(parser);
}
}
return 0;
}