]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/address: do not set family in config_parse_broadcast()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Oct 2024 06:08:04 +0000 (15:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Oct 2024 23:10:30 +0000 (08:10 +0900)
The family will be checked later in
address_section_verify() -> address_section_adjust_broadcast(),
hence it is not necessary to set here.

Follow-up for 5d15c7b19cae6d3332d4e213c380e0fcc1317a2c.

Fixes oss-fuzz#372994449.
Fixes #34748.

src/network/networkd-address.c
test/fuzz/fuzz-network-parser/oss-fuzz-372994449 [new file with mode: 0644]

index deffa4deadeba0712a1f21cda96dd62164880a82..228cb93fc823ea561d61fa44b497410ecab31136 100644 (file)
@@ -2033,9 +2033,12 @@ static int config_parse_broadcast(
         union in_addr_union u;
         int r;
 
+        /* Do not check or set address->family here. It will be checked later in
+         * address_section_verify() -> address_section_adjust_broadcast() . */
+
         if (isempty(rvalue)) {
                 /* The broadcast address will be calculated based on Address=, and set if the link is
-                 * not a wireguard interface. Here, we do not check or set address->family. */
+                 * not a wireguard interface. */
                 address->broadcast = (struct in_addr) {};
                 address->set_broadcast = -1;
                 return 1;
@@ -2043,8 +2046,7 @@ static int config_parse_broadcast(
 
         r = parse_boolean(rvalue);
         if (r >= 0) {
-                /* The broadcast address will be calculated based on Address=. Here, we do not check or
-                 * set address->family. */
+                /* The broadcast address will be calculated based on Address=. */
                 address->broadcast = (struct in_addr) {};
                 address->set_broadcast = r;
                 return 1;
@@ -2061,7 +2063,6 @@ static int config_parse_broadcast(
 
         address->broadcast = u.in;
         address->set_broadcast = true;
-        address->family = AF_INET;
         return 1;
 }
 
diff --git a/test/fuzz/fuzz-network-parser/oss-fuzz-372994449 b/test/fuzz/fuzz-network-parser/oss-fuzz-372994449
new file mode 100644 (file)
index 0000000..76c3a49
Binary files /dev/null and b/test/fuzz/fuzz-network-parser/oss-fuzz-372994449 differ