diff options
author | Michael Brown <mcb30@ipxe.org> | 2016-03-12 01:21:18 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2016-03-12 01:24:03 +0000 |
commit | 64acfd9ddd73bf38802f8c57e054d13a57b14198 (patch) | |
tree | 97a1d42de582670763f60d8b21a840f4dfde6059 /src/include/ipxe/if_arp.h | |
parent | 11396473f5878af70b0ec9714a03d81a0c05a771 (diff) | |
download | ipxe-64acfd9ddd73bf38802f8c57e054d13a57b14198.tar.gz |
[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>
Diffstat (limited to 'src/include/ipxe/if_arp.h')
-rw-r--r-- | src/include/ipxe/if_arp.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/include/ipxe/if_arp.h b/src/include/ipxe/if_arp.h index 4eb1f80b7..9d7b03fe8 100644 --- a/src/include/ipxe/if_arp.h +++ b/src/include/ipxe/if_arp.h @@ -99,4 +99,14 @@ static inline void * arp_target_pa ( struct arphdr *arphdr ) { return ( arp_target_ha ( arphdr ) + arphdr->ar_hln ); } +/** ARP packet length + * + * @v arphdr ARP header + * @ret len Length (including header) + */ +static inline size_t arp_len ( struct arphdr *arphdr ) { + return ( sizeof ( *arphdr ) + + ( 2 * ( arphdr->ar_hln + arphdr->ar_pln ) ) ); +} + #endif /* _IPXE_IF_ARP_H */ |