diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-12-19 11:27:10 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-08 12:34:59 +0200 |
commit | d9bcf2f3cc50e5d54f3180943292e2c18555c584 (patch) | |
tree | 96453f6e12fe27f222992401ccbb160bdcf813ec | |
parent | 08bc73532c11d113d3052a745f406fcbd808cd8f (diff) | |
download | NetworkManager-d9bcf2f3cc50e5d54f3180943292e2c18555c584.tar.gz |
dhcp: nettools: fix parsing of classless routes option
Fixes: 6adade6f21d5 ('dhcp: add nettools dhcp4 client')
(cherry picked from commit dd3114deb04184b38da6a9bd2d1e602985380c55)
(cherry picked from commit bee319bf9413f2584bcda288fb3d76935f50cc13)
-rw-r--r-- | src/dhcp/nm-dhcp-nettools.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c index 5428e7c98d..214aa5d5e5 100644 --- a/src/dhcp/nm-dhcp-nettools.c +++ b/src/dhcp/nm-dhcp-nettools.c @@ -148,6 +148,7 @@ lease_option_next_route (struct in_addr *destp, uint8_t *data = *datap; size_t n_data = *n_datap; uint8_t plen; + uint8_t bytes; if (classless) { if (!lease_option_consume (&plen, sizeof (plen), &data, &n_data)) @@ -156,7 +157,9 @@ lease_option_next_route (struct in_addr *destp, if (plen > 32) return FALSE; - if (!lease_option_consume (&dest, plen / 8, &data, &n_data)) + bytes = plen == 0 ? 0 : ((plen - 1) / 8) + 1; + + if (!lease_option_consume (&dest, bytes, &data, &n_data)) return FALSE; } else { if (!lease_option_next_in_addr (&dest, &data, &n_data)) |