Check datalink during fuzzing to prevent console / logfile spam. See #1175 for more information. (#1177)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
CC=@CC@
|
CC=@CC@
|
||||||
CXX=@CXX@
|
CXX=@CXX@
|
||||||
BUILD_MINGW=@BUILD_MINGW@
|
BUILD_MINGW=@BUILD_MINGW@
|
||||||
BUILD_FUZZTARGETS=@BUILD_FUZZTARGETS@
|
|
||||||
SRCHOME=../src
|
SRCHOME=../src
|
||||||
CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
|
CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
|
||||||
LIBNDPI=$(SRCHOME)/lib/libndpi.a
|
LIBNDPI=$(SRCHOME)/lib/libndpi.a
|
||||||
@@ -11,10 +10,6 @@ HEADERS=intrusion_detection.h reader_util.h $(SRCHOME)/include/ndpi_api.h \
|
|||||||
OBJS=ndpiReader.o reader_util.o intrusion_detection.o
|
OBJS=ndpiReader.o reader_util.o intrusion_detection.o
|
||||||
PREFIX?=@prefix@
|
PREFIX?=@prefix@
|
||||||
|
|
||||||
ifneq ($(BUILD_FUZZTARGETS),)
|
|
||||||
CFLAGS += -DBUILD_FUZZTARGETS=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(BUILD_MINGW),)
|
ifneq ($(BUILD_MINGW),)
|
||||||
all:
|
all:
|
||||||
@echo 'Examples disabled due to mingw build.'
|
@echo 'Examples disabled due to mingw build.'
|
||||||
|
|||||||
@@ -1775,15 +1775,11 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#ifndef BUILD_FUZZTARGETS
|
|
||||||
/*
|
/*
|
||||||
* We shoudn't be here, because we already checked that this datalink is supported.
|
* We shoudn't be here, because we already checked that this datalink is supported.
|
||||||
* Should ndpi_is_datalink_supported() be updated?
|
* Should ndpi_is_datalink_supported() be updated?
|
||||||
*
|
|
||||||
* NOTE (toni): We get here quite often during fuzzing and it spams consoles and logfiles. ;)
|
|
||||||
*/
|
*/
|
||||||
printf("Unknown datalink %d\n", datalink_type);
|
printf("Unknown datalink %d\n", datalink_type);
|
||||||
#endif
|
|
||||||
return(nproto);
|
return(nproto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||||||
free(pcap_path);
|
free(pcap_path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (ndpi_is_datalink_supported(pcap_datalink(pkts)) == 0)
|
||||||
|
{
|
||||||
|
/* Do not fail if the datalink type is not supported (may happen often during fuzzing). */
|
||||||
|
pcap_close(pkts);
|
||||||
|
remove(pcap_path);
|
||||||
|
free(pcap_path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
struct ndpi_workflow * workflow = ndpi_workflow_init(prefs, pkts);
|
struct ndpi_workflow * workflow = ndpi_workflow_init(prefs, pkts);
|
||||||
// enable all protocols
|
// enable all protocols
|
||||||
NDPI_BITMASK_SET_ALL(all);
|
NDPI_BITMASK_SET_ALL(all);
|
||||||
|
|||||||
Reference in New Issue
Block a user