]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp6: do not use input value before checking
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 22 Feb 2021 12:59:24 +0000 (21:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Feb 2021 09:49:11 +0000 (18:49 +0900)
src/libsystemd-network/dhcp6-option.c

index 9f47c1bbe4ce4a8ff6c41720614377ff0ee0e59c..48eef8950b673c7e2e1ebe4601a098416124a366 100644 (file)
@@ -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;