mirror of https://github.com/google/oss-fuzz.git
[lldpd] initial integration (#8577)
Hello @vincentbernat Can you check this PR? oss-fuzz team. Application usage in router: - Unifi, - Cambium Networks, - oVirt, - OpenWrt, - Poly, - MikroTik, - Cumulus, - ASUS. It is possibly used in other places as well. Signed-off-by: 0x34d <ajsinghyadav00@gmail.com> Signed-off-by: 0x34d <ajsinghyadav00@gmail.com>
This commit is contained in:
parent
4d41678f60
commit
8a06835d0d
|
@ -0,0 +1,22 @@
|
|||
# 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.
|
||||
#
|
||||
################################################################################
|
||||
FROM gcr.io/oss-fuzz-base/base-builder
|
||||
RUN apt-get update && apt-get install -y autoconf libtool-bin pkg-config
|
||||
RUN git clone --recursive https://github.com/lldpd/lldpd/
|
||||
RUN git clone https://github.com/0x34d/oss-fuzz-bloat
|
||||
COPY build.sh $SRC/
|
||||
COPY FuzzDecode.c $SRC/lldpd/FuzzDecode.c
|
||||
WORKDIR $SRC/lldpd/
|
|
@ -0,0 +1,45 @@
|
|||
/* 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 <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../src/daemon/lldpd.h"
|
||||
|
||||
#define kMinInputLength 30
|
||||
#define kMaxInputLength 1500
|
||||
|
||||
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
|
||||
if (Size < kMinInputLength || Size > kMaxInputLength){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
struct lldpd cfg;
|
||||
cfg.g_config.c_mgmt_pattern = NULL;
|
||||
|
||||
/* For decoding, we only need a very basic hardware */
|
||||
struct lldpd_hardware hardware;
|
||||
memset(&hardware, 0, sizeof(struct lldpd_hardware));
|
||||
hardware.h_mtu = 1500;
|
||||
strlcpy(hardware.h_ifname, "test", sizeof(hardware.h_ifname));
|
||||
|
||||
struct lldpd_chassis *nchassis = NULL;
|
||||
struct lldpd_port *nport = NULL;
|
||||
|
||||
//Decoding
|
||||
ret += lldp_decode(&cfg, (char *)Data, Size, &hardware, &nchassis, &nport);
|
||||
ret += cdp_decode(&cfg, (char *)Data, Size, &hardware, &nchassis, &nport);
|
||||
ret += sonmp_decode(&cfg, (char *)Data, Size, &hardware, &nchassis, &nport);
|
||||
ret += edp_decode(&cfg, (char *)Data, Size, &hardware, &nchassis, &nport);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash -eu
|
||||
# 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.
|
||||
#
|
||||
################################################################################
|
||||
./autogen.sh
|
||||
./configure CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" --disable-shared --disable-hardening --enable-pie
|
||||
make
|
||||
|
||||
$CC $CFLAGS -fPIE -Wall -Werror -pipe -DHAVE_CONFIG_H -I. -I include/ -c FuzzDecode.c
|
||||
$CC $CFLAGS -fPIE -pie -o FuzzDecode FuzzDecode.o $LIB_FUZZING_ENGINE src/daemon/.libs/liblldpd.a libevent/.libs/libevent.a
|
||||
cp FuzzDecode $OUT/FuzzDecode
|
||||
|
||||
pushd $SRC/oss-fuzz-bloat/lldpd/
|
||||
cp FuzzDecode_seed_corpus.zip $OUT/FuzzDecode_seed_corpus.zip
|
||||
popd
|
|
@ -0,0 +1,14 @@
|
|||
homepage: "https://lldpd.github.io"
|
||||
language: c
|
||||
primary_contact: "vincent@bernat.ch"
|
||||
auto_ccs:
|
||||
- "ajsinghyadav00@gmail.com"
|
||||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
- afl
|
||||
- honggfuzz
|
||||
sanitizers:
|
||||
- address
|
||||
- memory
|
||||
- undefined
|
||||
main_repo: 'https://github.com/lldpd/lldpd'
|
Loading…
Reference in New Issue