dhclient: Fix the trivial buffer overruns correctly

A DHCP client identifier is simply the hardware type (one byte) concatenated
with the hardware address (some variable number of bytes, but at most 16).
Limit the size of the temporary buffer to match and the rest of the
calculations shake out correctly.

This is a follow-up to the incorrect r299512, reverted in r300172.

CIDs:		1008682, 1305550
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Conrad Meyer 2016-05-18 23:41:55 +00:00
parent 14131c0ba4
commit fb0eab090e

View file

@ -1570,7 +1570,7 @@ make_discover(struct interface_info *ip, struct client_lease *lease)
}
/* set unique client identifier */
char client_ident[sizeof(struct hardware)];
char client_ident[sizeof(ip->hw_address.haddr) + 1];
if (!options[DHO_DHCP_CLIENT_IDENTIFIER]) {
int hwlen = (ip->hw_address.hlen < sizeof(client_ident)-1) ?
ip->hw_address.hlen : sizeof(client_ident)-1;