diff --git a/projects/lighttpd/Dockerfile b/projects/lighttpd/Dockerfile new file mode 100755 index 000000000..e27d80404 --- /dev/null +++ b/projects/lighttpd/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2021 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update && apt-get install -y libz-dev libtool pkg-config autoconf +RUN git clone https://github.com/lighttpd/lighttpd1.4 + +WORKDIR $SRC/lighttpd1.4 +COPY build.sh $SRC/ +COPY fuzz_* $SRC/ diff --git a/projects/lighttpd/build.sh b/projects/lighttpd/build.sh new file mode 100755 index 000000000..5cd286a7b --- /dev/null +++ b/projects/lighttpd/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash -eu +# Copyright 2021 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. +# +################################################################################ + +./autogen.sh +./configure --without-pcre --enable-static +make +cd src +$CC $CFLAGS -c $SRC/fuzz_burl.c -I. -I../include +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_burl.o burl.o buffer.o base64.o -o $OUT/fuzz_burl diff --git a/projects/lighttpd/fuzz_burl.c b/projects/lighttpd/fuzz_burl.c new file mode 100644 index 000000000..1914006c5 --- /dev/null +++ b/projects/lighttpd/fuzz_burl.c @@ -0,0 +1,57 @@ +/* Copyright 2021 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 +#include +#include +#include + +#include "burl.h" +#include "buffer.h" + +void run_burl_normalize (buffer *psrc, buffer *ptmp, + int flags, int line, const char *in, + size_t in_len) { + int qs; + buffer_copy_string_len(psrc, in, in_len); + qs = burl_normalize(psrc, ptmp, flags); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + if (size <= 4) { + return 0; + } + int flags = ((int*)data)[0]; + data += 4; + size -= 4; + char *new_str = (char *)malloc(size+1); + if (new_str == NULL){ + return 0; + } + memcpy(new_str, data, size); + new_str[size] = '\0'; + + /* main fuzzer entrypoint for library */ + buffer *psrc = buffer_init(); + buffer *ptmp = buffer_init(); + run_burl_normalize(psrc, ptmp, flags, __LINE__, new_str, size); + buffer_urldecode_path(psrc); + buffer_urldecode_query(psrc); + + buffer_free(psrc); + buffer_free(ptmp); + free(new_str); + return 0; +} diff --git a/projects/lighttpd/project.yaml b/projects/lighttpd/project.yaml new file mode 100755 index 000000000..9a4b44246 --- /dev/null +++ b/projects/lighttpd/project.yaml @@ -0,0 +1,6 @@ +homepage: "https://www.lighttpd.net/" +primary_contact: "lighttpd.fuzz@gmail.com" +language: c +auto_ccs : + - "david@adalogics.com" +main_repo: "https://github.com/lighttpd/lighttpd1.4"