diff --git a/projects/pupnp/Dockerfile b/projects/pupnp/Dockerfile index 9beebdf76..a902257de 100644 --- a/projects/pupnp/Dockerfile +++ b/projects/pupnp/Dockerfile @@ -14,9 +14,8 @@ # ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder -RUN apt-get update && apt-get install -y autoconf libtool-bin pkg-config +RUN apt-get update && apt-get install -y cmake RUN git clone https://github.com/pupnp/pupnp RUN git clone https://github.com/0x34d/oss-fuzz-bloat COPY build.sh $SRC/ -COPY FuzzIxml.c $SRC/pupnp/FuzzIxml.c WORKDIR $SRC/pupnp/ diff --git a/projects/pupnp/FuzzIxml.c b/projects/pupnp/FuzzIxml.c deleted file mode 100644 index 87bb6c795..000000000 --- a/projects/pupnp/FuzzIxml.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2022 Google LLC -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#include "ixml.h" -#include -#include -#include -#include -#include - -#define kMinInputLength 10 -#define kMaxInputLength 5120 - -int CheckXML(char *filename){ - - int rc; - DOMString s; - IXML_Document *doc = NULL; - - rc = ixmlLoadDocumentEx(filename, &doc); - if (rc != IXML_SUCCESS) { - return rc; - } - - s = ixmlPrintDocument(doc); - if (s == NULL || s[0] == '\0') { - ixmlDocument_free(doc); - return 1; - } - - ixmlFreeDOMString(s); - ixmlDocument_free(doc); - - return 0; -} - -extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - - if (Size < kMinInputLength || Size > kMaxInputLength){ - return 1; - } - - int ret; - char filename[256]; - - sprintf(filename, "/tmp/libfuzzer.%d", getpid()); - FILE *fp = fopen(filename, "wb"); - if (!fp) { - return 0; - } - - fwrite(Data, Size, 1, fp); - fclose(fp); - - ret = CheckXML(filename); - unlink(filename); - return ret; -} diff --git a/projects/pupnp/build.sh b/projects/pupnp/build.sh index 1f2571f13..0dc9c6b9b 100644 --- a/projects/pupnp/build.sh +++ b/projects/pupnp/build.sh @@ -14,16 +14,15 @@ # limitations under the License. # ################################################################################ -./bootstrap -./configure CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" --enable-debug --disable-shared + +export CXXFLAGS="$CFLAGS" + +mkdir build +cd build +cmake -DFUZZER=ON -DLIB_FUZZING_ENGINE="$LIB_FUZZING_ENGINE" ../ make -j$(nproc) -$CC $CFLAGS -fPIE -pipe -Wall -Wextra -DHAVE_CONFIG_H -DDEBUG -DIXML_HAVE_SCRIPTSUPPORT \ --I./ixml/inc/ -I./upnp/inc -c FuzzIxml.c - -$CXX $CFLAGS -fPIE -pipe -o FuzzIxml FuzzIxml.o $LIB_FUZZING_ENGINE ./ixml/.libs/libixml.a - -cp FuzzIxml $OUT/FuzzIxml +cp fuzzer/FuzzIxml $OUT/FuzzIxml pushd $SRC/oss-fuzz-bloat/pupnp/ cp FuzzIxml_seed_corpus.zip $OUT/FuzzIxml_seed_corpus.zip