diff --git a/.gitignore b/.gitignore index 12c8f647..1569c73e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,11 @@ examples/publish/basic-websockets-1 fuzzing/broker/broker_fuzz_initial_packet fuzzing/broker/broker_fuzz_second_packet fuzzing/corpora/broker/* +fuzzing/corpora/broker_packet_seed_corpus.zip fuzzing/corpora/client/* +fuzzing/corpora/client_packet_seed_corpus.zip +fuzzing/corpora/db_dump_seed_corpus.zip + lib/cpp/libmosquittopp.so* lib/cpp/libmosquittopp.a diff --git a/fuzzing/broker/Makefile b/fuzzing/broker/Makefile index 0b7e9583..f571d024 100644 --- a/fuzzing/broker/Makefile +++ b/fuzzing/broker/Makefile @@ -3,7 +3,8 @@ R=../.. FUZZERS:= \ broker_fuzz_initial_packet \ - broker_fuzz_second_packet + broker_fuzz_second_packet \ + broker_fuzz_test_config LOCAL_CPPFLAGS:=$(CPPFLAGS) -I${R}/include/ LOCAL_CXXFLAGS:=$(CXXFLAGS) -g -Wall -Werror -pthread @@ -22,5 +23,11 @@ broker_fuzz_second_packet : broker_fuzz_second_packet.cpp broker_fuzz.cpp install $@ ${OUT}/$@ cp ${R}/fuzzing/corpora/broker_packet_seed_corpus.zip ${OUT}/$@_seed_corpus.zip +broker_fuzz_test_config : broker_fuzz_test_config.cpp + $(CXX) $(LOCAL_CXXFLAGS) $(LOCAL_CPPFLAGS) $(LOCAL_LDFLAGS) -o $@ $^ $(LOCAL_LIBADD) + install $@ ${OUT}/$@ + cp ${R}/fuzzing/corpora/broker_fuzz_test_config_seed_corpus.zip ${OUT}/$@_seed_corpus.zip + cp ${R}/fuzzing/corpora/broker_conf.dict ${OUT}/$@.dict + clean: rm -f *.o $(FUZZERS) diff --git a/fuzzing/broker/broker_fuzz_test_config.cpp b/fuzzing/broker/broker_fuzz_test_config.cpp new file mode 100644 index 00000000..0eee3bcb --- /dev/null +++ b/fuzzing/broker/broker_fuzz_test_config.cpp @@ -0,0 +1,67 @@ +/* +Copyright (c) 2023 Cedalo GmbH + +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License 2.0 +and Eclipse Distribution License v1.0 which accompany this distribution. + +The Eclipse Public License is available at + https://www.eclipse.org/legal/epl-2.0/ +and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +Contributors: + Roger Light - initial implementation and documentation. +*/ + +#include +#include +#include +#include +#include + +/* + * Broker check of config only, the config isn't used + */ + +/* The broker fuzz-only main function. */ +extern "C" int mosquitto_fuzz_main(int argc, char *argv[]); + +void run_broker(char *filename) +{ + char *argv[4]; + int argc = 4; + + argv[0] = strdup("mosquitto"); + argv[1] = strdup("--test-config"); + argv[2] = strdup("-c"); + argv[3] = strdup(filename); + + mosquitto_fuzz_main(argc, argv); + + for(int i=0; i