]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp6: tighten T1 and T2 value check 18777/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Feb 2021 11:07:04 +0000 (20:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Mar 2021 20:51:56 +0000 (05:51 +0900)
Only when T1 and T2 are both 0, they are adjusted later based on
address or prefix T1 and T2. So the first check must be changed.

src/libsystemd-network/dhcp6-option.c

index cf3c7c287a549142157f4e73515a9f39d7574013..daaa940f97f61b8f4e6db2840d2e2fd601366a21 100644 (file)
@@ -535,7 +535,7 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
                 lt_t1 = be32toh(ia->ia_na.lifetime_t1);
                 lt_t2 = be32toh(ia->ia_na.lifetime_t2);
 
-                if (lt_t1 && lt_t2 && lt_t1 > lt_t2)
+                if (lt_t1 > lt_t2)
                         return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
                                                       "IA NA T1 %"PRIu32"sec > T2 %"PRIu32"sec",
                                                       lt_t1, lt_t2);
@@ -553,7 +553,7 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
                 lt_t1 = be32toh(ia->ia_pd.lifetime_t1);
                 lt_t2 = be32toh(ia->ia_pd.lifetime_t2);
 
-                if (lt_t1 && lt_t2 && lt_t1 > lt_t2)
+                if (lt_t1 > lt_t2)
                         return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
                                                       "IA PD T1 %"PRIu32"sec > T2 %"PRIu32"sec",
                                                       lt_t1, lt_t2);
@@ -642,7 +642,7 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
 
         switch(iatype) {
         case SD_DHCP6_OPTION_IA_NA:
-                if (!ia->ia_na.lifetime_t1 && !ia->ia_na.lifetime_t2 && lt_min != UINT32_MAX) {
+                if (ia->ia_na.lifetime_t1 == 0 && ia->ia_na.lifetime_t2 == 0 && lt_min != UINT32_MAX) {
                         lt_t1 = lt_min / 2;
                         lt_t2 = lt_min / 10 * 8;
                         ia->ia_na.lifetime_t1 = htobe32(lt_t1);
@@ -655,7 +655,7 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
                 break;
 
         case SD_DHCP6_OPTION_IA_PD:
-                if (!ia->ia_pd.lifetime_t1 && !ia->ia_pd.lifetime_t2 && lt_min != UINT32_MAX) {
+                if (ia->ia_pd.lifetime_t1 == 0 && ia->ia_pd.lifetime_t2 == 0 && lt_min != UINT32_MAX) {
                         lt_t1 = lt_min / 2;
                         lt_t2 = lt_min / 10 * 8;
                         ia->ia_pd.lifetime_t1 = htobe32(lt_t1);