diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2018-01-04 15:11:41 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2018-01-04 15:22:43 +0200 |
commit | 3bc424a3cc0bacc688ec2f4f93a5560fb4ca393b (patch) | |
tree | d664034b7e4deeb005a5d6566990b111c78ea327 /src/libsystemd-network/dhcp6-internal.h | |
parent | e0026dcbd21b172d51ac05e476044ac9504c1f71 (diff) | |
download | systemd-3bc424a3cc0bacc688ec2f4f93a5560fb4ca393b.tar.gz |
dhcp6: Sanitize DHCPv6 IA option parsing
Sanitize code for parsing DHCPv6 IA NA and TA options and their
nested Status options so that the options can be fully and
properly ignored should they not be conformant to the specification.
Do this by defining a proper DHCP6Option structure and sending that
structure to the parsing function. The parsing function will then
not manipulate either any option data pointers or their lengths in
order to iterate over the current option. Needless to say, this
affects a few files including the test program.
Diffstat (limited to 'src/libsystemd-network/dhcp6-internal.h')
-rw-r--r-- | src/libsystemd-network/dhcp6-internal.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libsystemd-network/dhcp6-internal.h b/src/libsystemd-network/dhcp6-internal.h index 9bff5c2dcd..9e7d3976aa 100644 --- a/src/libsystemd-network/dhcp6-internal.h +++ b/src/libsystemd-network/dhcp6-internal.h @@ -29,6 +29,13 @@ #include "macro.h" #include "sparse-endian.h" +/* Common option header */ +typedef struct DHCP6Option { + be16_t code; + be16_t len; + uint8_t data[]; +} _packed_ DHCP6Option; + typedef struct DHCP6Address DHCP6Address; struct DHCP6Address { @@ -76,8 +83,7 @@ int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia); int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn); int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode, size_t *optlen, uint8_t **optvalue); -int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype, - DHCP6IA *ia); +int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia); int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen, struct in6_addr **addrs, size_t count, size_t *allocated); |