diff --git a/projects/postfix/Dockerfile b/projects/postfix/Dockerfile new file mode 100644 index 000000000..68d8b1bff --- /dev/null +++ b/projects/postfix/Dockerfile @@ -0,0 +1,22 @@ +# 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 make autoconf automake libtool libdb-dev +RUN git clone --depth=1 https://github.com/vdukhovni/postfix postfix +WORKDIR postfix +COPY build.sh $SRC/ +COPY *.c $SRC/ diff --git a/projects/postfix/build.sh b/projects/postfix/build.sh new file mode 100755 index 000000000..d4d18fb95 --- /dev/null +++ b/projects/postfix/build.sh @@ -0,0 +1,32 @@ +#!/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. +# +################################################################################ + +cd postfix +make makefiles CCARGS="${CFLAGS}" +make +BASE=$PWD + +# Compile fuzzers +cd ${BASE}/src/global +$CC $CFLAGS -DHAS_DEV_URANDOM -DSNAPSHOT -UUSE_DYNAMIC_LIBS -DDEF_SHLIB_DIR=\"no\" \ + -UUSE_DYNAMIC_MAPS -I. -I../../include -DNO_EAI -DDEF_SMTPUTF8_ENABLE=\"no\" \ + -g -O -DLINUX4 -Wformat -Wno-comment -fno-common -c $SRC/fuzz_tok822.c + +# Link fuzzers +cd ${BASE} +$CC $CFLAGS $LIB_FUZZING_ENGINE ./src/global/fuzz_tok822.o -o $OUT/fuzz_tok822 \ + ./lib/libglobal.a ./lib/libutil.a diff --git a/projects/postfix/fuzz_tok822.c b/projects/postfix/fuzz_tok822.c new file mode 100644 index 000000000..d01b60985 --- /dev/null +++ b/projects/postfix/fuzz_tok822.c @@ -0,0 +1,49 @@ +/* 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 +#include + +#include + +#include "lex_822.h" +#include "quote_822_local.h" +#include "tok822.h" + + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + char *new_str = (char *)malloc(size+1); + if (new_str == NULL){ + return 0; + } + memcpy(new_str, data, size); + new_str[size] = '\0'; + + VSTRING *vp = vstring_alloc(100); + TOK822 *list = NULL; + list = tok822_parse_limit(new_str, 10); + tok822_internalize(vp, list, TOK822_STR_DEFL); + tok822_externalize(vp, list,TOK822_STR_DEFL | TOK822_STR_TRNC); + tok822_externalize(vp, list,TOK822_STR_DEFL | TOK822_STR_LINE | TOK822_STR_TRNC); + tok822_free_tree(list); + vstring_free(vp); + + free(new_str); + return 0; +} diff --git a/projects/postfix/project.yaml b/projects/postfix/project.yaml new file mode 100644 index 000000000..d284472c4 --- /dev/null +++ b/projects/postfix/project.yaml @@ -0,0 +1,8 @@ +homepage: "http://www.postfix.org/" +language: c +primary_contact: "wietse@gmail.com" +main_repo: "https://github.com/vdukhovni/postfix" +auto_ccs: + - "david@adalogics.com" +sanitizers: + - address