MINOR: connection: Transform safety check in PROXYv2 parsing into BUG_ON()

With BUG_ON() being enabled by default it is more useful to use a BUG_ON()
instead of an effectively never-taken if, as any incorrect assumptions will
become much more visible.

see 488ee7fb6 ("BUG/MAJOR: proxy_protocol: Properly validate TLV lengths")
This commit is contained in:
Tim Duesterhus 2022-02-25 21:44:27 +01:00 committed by Willy Tarreau
parent f09af57df5
commit 17e6b737d7
1 changed files with 4 additions and 5 deletions

View File

@ -1098,12 +1098,11 @@ int conn_recv_proxy(struct connection *conn, int flag)
}
/* Verify that the PROXYv2 header ends at a TLV boundary.
* This is technically unreachable, because the TLV parsing already
* verifies that a TLV does not exceed the total length and also
* that there is space for a TLV header.
* This is can not be true, because the TLV parsing already
* verifies that a TLV does not exceed the total length and
* also that there is space for a TLV header.
*/
if (tlv_offset != total_v2_len)
goto bad_header;
BUG_ON(tlv_offset != total_v2_len);
/* unsupported protocol, keep local connection address */
break;