eigrpd: fix byte order in Hello authentication decode - #21545
Conversation
Greptile SummaryThis PR fixes a network byte order bug in The fix β wrapping both fields with Confidence Score: 5/5Safe to merge β the fix is minimal, correct, and directly mirrors the encoding used in the send path. The change is a four-line, mechanical byte-order correction with no logic complexity. The No files require special attention; the only changed file applies the fix correctly. Important Files Changed
Sequence DiagramsequenceDiagram
participant Wire as Network Wire
participant Recv as eigrp_hello_receive
participant Decode as eigrp_hello_authentication_decode
participant Check as eigrp_check_md5_digest
Wire->>Recv: Hello packet (fields in network byte order)
Recv->>Recv: ntohs(tlv_header->type) β EIGRP_TLV_AUTH
Recv->>Decode: pass raw tlv_header pointer
Note over Decode: BEFORE fix: auth_type compared without ntohs,<br/>always fails on little-endian hosts
Note over Decode: AFTER fix: ntohs(md5->auth_type) == EIGRP_AUTH_TYPE_MD5
Note over Decode: AFTER fix: ntohs(md5->length) validates TLV size
alt auth type matches and length valid
Decode->>Check: eigrp_check_md5_digest or eigrp_check_sha256_digest
Check-->>Decode: pass or fail result
Decode-->>Recv: result (1 = ok, 0 = drop)
else no match
Decode-->>Recv: 0 drop packet
end
Recv->>Recv: if 0 return early, else continue
Reviews (1): Last reviewed commit: "eigrpd: fix byte order in Hello authenti..." | Re-trigger Greptile |
mjstapp
left a comment
There was a problem hiding this comment.
the greptile review notes another couple of places that may have the same issue: can you add those to the PR?
|
Good catch. Added ntohs() to the parameter, software version, and peer termination decode functions in the latest push. |
|
ah: please rebase and squash/fixup the second commit into the first, no need to have two commits there (and the commit-format checker is flagging it anyway) |
The auth_type and length fields in EIGRP Hello TLV structures are network byte order, but several decode functions compare them against host-order constants without ntohs(). Add ntohs() to all affected comparisons: - eigrp_hello_authentication_decode: auth_type and length checks - eigrp_hello_parameter_decode: length check - eigrp_sw_version_decode: length check - eigrp_peer_termination_decode: length check Signed-off-by: Tristan Madani <tristan@live.fr>
90c7935 to
b8e6379
Compare
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0 |
β Backports have been createdDetails
|
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrpd: fix byte order in Hello authentication decode (backport #21545)
eigrp_hello_authentication_decode()comparesmd5->auth_typeandmd5->lengthdirectly against host-order constants, but these struct fields are stored in network byte order (the send path useshtons()ateigrp_packet.c:1248). On little-endian hosts the comparisons never match, so authentication is silently skipped.Wrap both fields with
ntohs()to match the encoding.Signed-off-by: Tristan Madani tristan@live.fr