mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
BUG/MINOR: connection: parse PROXY TLV for LOCAL mode
conn_recv_proxy() is responsible to parse PROXY protocol header. For v2 of the protocol, TLVs parsing is implemented. However, this step was only done inside 'PROXY' command label. TLVs were never extracted for 'LOCAL' command mode. Fix this by extracting TLV parsing loop outside of the switch case. Of notable importance, tlv_offset is updated on LOCAL label to point to first TLV location. This bug should be backported up to 2.9 at least. It should even probably be backported to every stable versions. Note however that this code has changed much over time. It may be useful to use option '--ignore-all-space' to have a clearer overview of the git diff.
This commit is contained in:
parent
eb89a7da33
commit
8b72270e95
@ -1129,6 +1129,17 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
break;
|
||||
}
|
||||
|
||||
/* unsupported protocol, keep local connection address */
|
||||
break;
|
||||
case 0x00: /* LOCAL command */
|
||||
/* keep local connection address for LOCAL */
|
||||
|
||||
tlv_offset = PP2_HEADER_LEN;
|
||||
break;
|
||||
default:
|
||||
goto bad_header; /* not a supported command */
|
||||
}
|
||||
|
||||
/* TLV parsing */
|
||||
while (tlv_offset < total_v2_len) {
|
||||
struct ist tlv;
|
||||
@ -1217,7 +1228,6 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
LIST_APPEND(&conn->tlv_list, &new_tlv->list);
|
||||
}
|
||||
|
||||
|
||||
/* Verify that the PROXYv2 header ends at a TLV boundary.
|
||||
* This is can not be true, because the TLV parsing already
|
||||
* verifies that a TLV does not exceed the total length and
|
||||
@ -1225,15 +1235,6 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
*/
|
||||
BUG_ON(tlv_offset != total_v2_len);
|
||||
|
||||
/* unsupported protocol, keep local connection address */
|
||||
break;
|
||||
case 0x00: /* LOCAL command */
|
||||
/* keep local connection address for LOCAL */
|
||||
break;
|
||||
default:
|
||||
goto bad_header; /* not a supported command */
|
||||
}
|
||||
|
||||
trash.data = total_v2_len;
|
||||
goto eat_header;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user