mirror of https://github.com/google/oss-fuzz.git
[expat] working build & simple fuzzer from chrome.
This commit is contained in:
parent
e0b3abddf8
commit
d3df019019
|
@ -16,5 +16,6 @@
|
||||||
|
|
||||||
FROM ossfuzz/base-libfuzzer
|
FROM ossfuzz/base-libfuzzer
|
||||||
MAINTAINER mike.aizatsky@gmail.com
|
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
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
#!/bin/bash -ex
|
#!/bin/bash -ex
|
||||||
|
. /env
|
||||||
|
|
||||||
echo $pwd
|
cd /workspace/expat
|
||||||
|
|
||||||
ls -alR
|
ls -alR
|
||||||
|
|
||||||
./buildconf.sh
|
./buildconf.sh
|
||||||
./configure
|
./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
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue