diff --git a/projects/coturn/Dockerfile b/projects/coturn/Dockerfile index 57d3be095..3b511f53d 100644 --- a/projects/coturn/Dockerfile +++ b/projects/coturn/Dockerfile @@ -15,9 +15,7 @@ ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder -RUN apt-get update && apt-get install -y pkg-config libssl-dev libevent-dev +RUN apt-get update && apt-get install -y cmake libssl-dev libevent-dev RUN git clone https://github.com/coturn/coturn -RUN git clone https://github.com/0x34d/oss-fuzz-bloat COPY build.sh $SRC/ -COPY fuzz/ $SRC/coturn/fuzz/ WORKDIR $SRC/coturn/ diff --git a/projects/coturn/build.sh b/projects/coturn/build.sh index 4dd87c56d..6fdfe667d 100644 --- a/projects/coturn/build.sh +++ b/projects/coturn/build.sh @@ -15,13 +15,29 @@ # ################################################################################ -cd fuzz -make all +mkdir my_build +pushd my_build/ +cmake -DFUZZER=ON -DLIB_FUZZING_ENGINE="$LIB_FUZZING_ENGINE" -DWITH_MYSQL=OFF -Wno-dev ../. +make -j$(nproc) +popd + +pushd my_build/fuzzing/ cp FuzzStun $OUT/FuzzStun cp FuzzStunClient $OUT/FuzzStunClient +popd -pushd $SRC/oss-fuzz-bloat/coturn/ +pushd fuzzing/input/ cp FuzzStun_seed_corpus.zip $OUT/FuzzStun_seed_corpus.zip cp FuzzStunClient_seed_corpus.zip $OUT/FuzzStunClient_seed_corpus.zip popd + +pushd $OUT/ +mkdir $OUT/lib/ +patchelf --set-rpath '$ORIGIN/lib' FuzzStun +patchelf --set-rpath '$ORIGIN/lib' FuzzStunClient +popd + +pushd /lib/x86_64-linux-gnu/ +cp libevent* $OUT/lib/. +popd diff --git a/projects/coturn/fuzz/FuzzStun.c b/projects/coturn/fuzz/FuzzStun.c deleted file mode 100644 index f11a96bec..000000000 --- a/projects/coturn/fuzz/FuzzStun.c +++ /dev/null @@ -1,39 +0,0 @@ -/* 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 -#include -#include - -#include "ns_turn_utils.h" -#include "apputils.h" -#include "stun_buffer.h" - -static SHATYPE shatype = SHATYPE_SHA1; - -#define kMinInputLength 5 -#define kMaxInputLength 10240 - -extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {//rfc5769check - - if (Size < kMinInputLength || Size > kMaxInputLength){ - return 1; - } - - stun_is_command_message_full_check_str((uint8_t *)Data, Size, 1, NULL); - - uint8_t uname[33]; - uint8_t realm[33]; - uint8_t upwd[33]; - strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt"); - stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM,(uint8_t *)Data, Size, uname, realm, upwd, shatype); - return 0; -} diff --git a/projects/coturn/fuzz/FuzzStunClient.c b/projects/coturn/fuzz/FuzzStunClient.c deleted file mode 100644 index 7a31e3bfe..000000000 --- a/projects/coturn/fuzz/FuzzStunClient.c +++ /dev/null @@ -1,45 +0,0 @@ -/* 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 -#include -#include - -#include "ns_turn_utils.h" -#include "apputils.h" -#include "stun_buffer.h" - -#define kMinInputLength 5 -#define kMaxInputLength 10240 - -extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {//stunclient.c - - if (Size < kMinInputLength || Size > kMaxInputLength){ - return 1; - } - - stun_buffer buf; - - buf.len = Size; - memcpy(buf.buf,Data,buf.len); - - if(stun_is_command_message(&buf)){ - if(stun_is_response(&buf)){ - if(stun_is_success_response(&buf)){ - if(stun_is_binding_response(&buf)){ - return 0; - } - } - } - } - - return 1; -} diff --git a/projects/coturn/fuzz/Makefile b/projects/coturn/fuzz/Makefile deleted file mode 100644 index 3e9851008..000000000 --- a/projects/coturn/fuzz/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -TARGET=Fuzzer - -#EXEFuzzer -FUZZSTUN=FuzzStun -FUZZSTUNCLIENT=FuzzStunClient - -#Tag -SET=cd ../ && -EXTCFLAGS= -Wall -Wextra -TAG=-DLIBEV_OK -DTURN_HAS_DAEMON -DTURN_NO_PROMETHEUS -INC=-I../src -I../src/apps/common -I../src/server -I../src/client -I../src/client++ -LIBINC=-L../lib/ -lturnclient -LIB=$(LIBINC) -lssl -lcrypto -stun_buffer=../src/apps/common/stun_buffer.c - - -all: $(TARGET) - -CONF: - $(SET) CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(CFLAGS)" ./configure -MAKEALL: - $(SET) make all - -$(TARGET): CONF MAKEALL - $(CC) $(EXTCFLAGS) $(CFLAGS) $(TAG) $(INC) -c $(FUZZSTUN).c - $(CXX) $(CFLAGS) $(LIB_FUZZING_ENGINE) $(FUZZSTUN).o -o $(FUZZSTUN) $(LIB) - - $(CC) $(EXTCFLAGS) $(CFLAGS) $(TAG) $(INC) -c $(FUZZSTUNCLIENT).c - $(CC) $(EXTCFLAGS) $(CFLAGS) $(TAG) $(INC) -c $(stun_buffer) - $(CXX) $(CFLAGS) $(LIB_FUZZING_ENGINE) $(FUZZSTUNCLIENT).o stun_buffer.o -o $(FUZZSTUNCLIENT) $(LIB) - -clean: - rm $(FUZZSTUN) $(FUZZSTUNCLIENT) *.o - -reallyclean: clean - $(SET) make clean - -.PHONY: all clean reallyclean