mirror of
https://github.com/ipxe/ipxe
synced 2025-12-13 15:31:42 +03:00
[arp] Validate length of ARP packet
There is no practical way to generate an underlength ARP packet since an ARP packet is always padded up to the minimum Ethernet frame length (or dropped by the receiving Ethernet hardware if incorrectly padded), but the absence of an explicit check causes warnings from some analysis tools. Fix by adding an explicit check on the I/O buffer length. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -139,8 +139,15 @@ static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
|
||||
struct arp_net_protocol *arp_net_protocol;
|
||||
struct net_protocol *net_protocol;
|
||||
struct ll_protocol *ll_protocol;
|
||||
size_t len = iob_len ( iobuf );
|
||||
int rc;
|
||||
|
||||
/* Sanity check */
|
||||
if ( ( len < sizeof ( *arphdr ) ) || ( len < arp_len ( arphdr ) ) ) {
|
||||
rc = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Identify network-layer and link-layer protocols */
|
||||
arp_net_protocol = arp_find_protocol ( arphdr->ar_pro );
|
||||
if ( ! arp_net_protocol ) {
|
||||
|
||||
Reference in New Issue
Block a user