From: Philippe Antoine Date: Mon, 22 Nov 2021 14:08:52 +0000 (+0100) Subject: fuzz: restrict flags passed to AppLayerProtoDetectGetProto X-Git-Tag: suricata-7.0.0-beta1~1158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6634%2Fhead;p=thirdparty%2Fsuricata.git fuzz: restrict flags passed to AppLayerProtoDetectGetProto So that rust does not panic with an unhandled value --- diff --git a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c index 0a8095c8ae..8633a536f9 100644 --- a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c +++ b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c @@ -54,7 +54,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) f->protoctx = &ssn; f->protomap = FlowGetProtoMapping(f->proto); - alproto = AppLayerProtoDetectGetProto(alpd_tctx, f, data+HEADER_LEN, size-HEADER_LEN, f->proto, data[0], &reverse); + uint8_t flags = STREAM_TOCLIENT; + if (data[0] & STREAM_TOSERVER) { + flags = STREAM_TOSERVER; + } + alproto = AppLayerProtoDetectGetProto( + alpd_tctx, f, data + HEADER_LEN, size - HEADER_LEN, f->proto, flags, &reverse); if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED && f->proto == IPPROTO_TCP && (data[0] & STREAM_MIDSTREAM) == 0) { /* If we find a valid protocol at the start of a stream :