doh2: handle http1->http2->doh2 upgrade in one packet

Ticket: 8973

Before that, the update to DoH2 happened before http1 state was
freed, leading to a type confusion.

In case of a HTTP1->HTTP2 upgrade, if the client sends a DOH2
request, Suricata went to change again the flow's alproto
with SCAppLayerForceProtocolChange

But SCAppLayerForceProtocolChange did not take into account the
fact that we were doing a HTTP1->HTTP2 upgrade, and the previous
HTTP1 state was not freed yet.

Now SCAppLayerForceProtocolChange checks FlowChangeProto
and update alproto_orig only if we were not doing a proto change
already, as alproto_orig is used to know which type of state
to free.
pull/16213/head
Philippe Antoine 2 months ago committed by Victor Julien
parent 8c9bca92fb
commit c9ca1a4fba

@ -1884,7 +1884,14 @@ bool SCAppLayerRequestProtocolTLSUpgrade(Flow *f)
void SCAppLayerForceProtocolChange(Flow *f, AppProto new_proto)
{
if (new_proto != f->alproto) {
f->alproto_orig = f->alproto;
if (!FlowChangeProto(f)) {
// may happen when changing protocol from http1 to http2, then doh2
// We need to keep the original alproto, as HTTP1 state was not freed yet
f->alproto_orig = f->alproto;
} else if (f->alproto == f->alproto_expect) {
// First change went as expected
f->alproto_expect = new_proto;
}
f->alproto = new_proto;
f->alproto_ts = f->alproto;
f->alproto_tc = f->alproto;

Loading…
Cancel
Save