]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: fix assertions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 19 Oct 2021 11:23:47 +0000 (20:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Oct 2021 13:39:43 +0000 (22:39 +0900)
src/libsystemd-network/dhcp-network.c

index 0e3814c6baa5ecce03425b867c243af1a8ad8533..ae802f84b7d908769844aa5a55681a2c9f8c7818 100644 (file)
@@ -212,9 +212,12 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
 int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
                                  const void *packet, size_t len) {
 
+        /* Do not add assert(s >= 0) here, as this is called in fuzz-dhcp-server, and in that case this
+         * function should fail with negative errno. */
+
         assert(link);
         assert(packet);
-        assert(len);
+        assert(len > 0);
 
         if (sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll)) < 0)
                 return -errno;
@@ -232,7 +235,7 @@ int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
 
         assert(s >= 0);
         assert(packet);
-        assert(len);
+        assert(len > 0);
 
         if (sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in)) < 0)
                 return -errno;