diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-22 21:59:24 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-23 18:49:11 +0900 |
commit | cf6c33bd6b6ca606f0756312bd73ae066c6aa9a8 (patch) | |
tree | 4f4b36279be73fca301dc5d5f2c2fe0e9c103763 /src/libsystemd-network | |
parent | 2b767e9222809103cb756e368f0d71e906623bca (diff) | |
download | systemd-cf6c33bd6b6ca606f0756312bd73ae066c6aa9a8.tar.gz |
dhcp6: do not use input value before checking
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/dhcp6-option.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c index 9f47c1bbe4..48eef8950b 100644 --- a/src/libsystemd-network/dhcp6-option.c +++ b/src/libsystemd-network/dhcp6-option.c @@ -41,14 +41,15 @@ typedef struct DHCP6PDPrefixOption { #define DHCP6_OPTION_IA_PD_LEN (sizeof(struct ia_pd)) #define DHCP6_OPTION_IA_TA_LEN (sizeof(struct ia_ta)) -static int option_append_hdr(uint8_t **buf, size_t *buflen, uint16_t optcode, - size_t optlen) { - DHCP6Option *option = (DHCP6Option*) *buf; +static int option_append_hdr(uint8_t **buf, size_t *buflen, uint16_t optcode, size_t optlen) { + DHCP6Option *option; assert_return(buf, -EINVAL); assert_return(*buf, -EINVAL); assert_return(buflen, -EINVAL); + option = (DHCP6Option*) *buf; + if (optlen > 0xffff || *buflen < optlen + offsetof(DHCP6Option, data)) return -ENOBUFS; |