mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
dhcp: fix transaction-id check so it actually compares
The guard read `if (!DHCP_P->tid == HTONS(...))`. Unary `!` binds tighter than `==`, so this evaluated `(!tid) == HTONS(id)`, i.e. `(tid ? 0 : 1) == HTONS(id)`, which is false for any non-zero id and never returns. The reply was therefore accepted regardless of its transaction id, so a broadcast reply meant for another client on the segment was parsed as ours. Compare the field directly. The id is stored network-order in the packet and host-order in the state, matching the HTONS() used when the request is built, so `DHCP_P->tid != HTONS(dhcp_state.transaction_id)` is the intended test.
This commit is contained in:
1 parent
12c15603ed
commit
dc5cbcda16
1 file changed
+1
-1
@@ -300,7 +300,7 @@ void parse_opts(void)
|
||||
|
||||
void parse_dhcp(void)
|
||||
{
|
||||
if (!DHCP_P->tid == HTONS(dhcp_state.transaction_id))
|
||||
if (DHCP_P->tid != HTONS(dhcp_state.transaction_id))
|
||||
return;
|
||||
if (DHCP_P->cookie[0] != 0x63 || DHCP_P->cookie[1] != 0x82 || DHCP_P->cookie[2] != 0x53 || DHCP_P->cookie[3] != 0x63)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user