diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-10-19 13:23:47 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-10-21 15:39:43 +0200 |
commit | b8319d748f1d03ff1524e63f8c0c42c838fd8486 (patch) | |
tree | e436ca6fb1b136ea99468c5e58821c7f4516caed /src/libsystemd-network | |
parent | dhcp: shorten code a bit (diff) | |
download | systemd-b8319d748f1d03ff1524e63f8c0c42c838fd8486.tar.xz systemd-b8319d748f1d03ff1524e63f8c0c42c838fd8486.zip |
dhcp: fix assertions
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/dhcp-network.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libsystemd-network/dhcp-network.c b/src/libsystemd-network/dhcp-network.c index 0e3814c6ba..ae802f84b7 100644 --- a/src/libsystemd-network/dhcp-network.c +++ b/src/libsystemd-network/dhcp-network.c @@ -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; |