mirror of https://github.com/google/oss-fuzz.git
add fuzzer for libteken (#47)
This commit is contained in:
parent
59f3805868
commit
2915f19758
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# 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 ossfuzz/base-libfuzzer
|
||||
MAINTAINER kcwu@csie.org
|
||||
RUN apt-get install -y pmake
|
||||
RUN svn co https://svn.freebsd.org/base/head/sys/teken
|
||||
COPY build.sh libteken_fuzzer.c /src/
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2016 Google Inc.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
def libfuzzerBuild = fileLoader.fromGit('infra/libfuzzer-pipeline.groovy',
|
||||
'https://github.com/google/oss-fuzz.git')
|
||||
|
||||
libfuzzerBuild {
|
||||
svn = "https://svn.freebsd.org/base/head/sys/teken"
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash -eu
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# 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 /src
|
||||
|
||||
# build the library.
|
||||
pmake -C teken/libteken teken_state.h
|
||||
CFLAGS="$CFLAGS -D__unused=" pmake -C teken/libteken libteken.a
|
||||
|
||||
# build your fuzzer(s)
|
||||
$CC $CFLAGS -Iteken \
|
||||
-o /out/libteken_fuzzer \
|
||||
libteken_fuzzer.c \
|
||||
-lfuzzer teken/libteken/libteken.a $FUZZER_LDFLAGS
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <teken.h>
|
||||
|
||||
static void dummy_bell(void *s) {}
|
||||
static void dummy_cursor(void *s, const teken_pos_t *p) {}
|
||||
static void dummy_putchar(void *s, const teken_pos_t *p, teken_char_t c,
|
||||
const teken_attr_t *a) {}
|
||||
static void dummy_fill(void *s, const teken_rect_t *r, teken_char_t c,
|
||||
const teken_attr_t *a) {}
|
||||
static void dummy_copy(void *s, const teken_rect_t *r, const teken_pos_t *p) {}
|
||||
static void dummy_param(void *s, int cmd, unsigned int value) {}
|
||||
static void dummy_respond(void *s, const void *buf, size_t len) {}
|
||||
|
||||
static teken_funcs_t tf = {
|
||||
.tf_bell = dummy_bell,
|
||||
.tf_cursor = dummy_cursor,
|
||||
.tf_putchar = dummy_putchar,
|
||||
.tf_fill = dummy_fill,
|
||||
.tf_copy = dummy_copy,
|
||||
.tf_param = dummy_param,
|
||||
.tf_respond = dummy_respond,
|
||||
};
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
teken_t t;
|
||||
teken_init(&t, &tf, NULL);
|
||||
teken_input(&t, data, size);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue