postfix: initial integration (#6775)

* postfix: initial integration

* postfix; fix build

* postfix: add Wietse`s email

* postfix: avoid warnings when compiling fuzzer
This commit is contained in:
DavidKorczynski 2021-11-09 15:29:37 +00:00 committed by GitHub
parent 7efdd06e03
commit 3c6e96cc94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 0 deletions

View File

@ -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/

32
projects/postfix/build.sh Executable file
View File

@ -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

View File

@ -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 <sys_defs.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <vstring.h>
#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;
}

View File

@ -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