1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

arp-util: check sent message size

This commit is contained in:
Yu Watanabe 2021-06-18 15:17:11 +09:00
parent 51d113512f
commit f6720fe62e

View File

@ -112,7 +112,7 @@ static int arp_send_packet(
.ea_hdr.ar_pln = sizeof(be32_t), /* PLEN */
.ea_hdr.ar_op = htobe16(ARPOP_REQUEST), /* REQUEST */
};
int r;
ssize_t n;
assert(fd >= 0);
assert(pa != 0);
@ -124,9 +124,11 @@ static int arp_send_packet(
if (announce)
memcpy(&arp.arp_spa, &pa, sizeof(pa));
r = sendto(fd, &arp, sizeof(struct ether_arp), 0, &link.sa, sizeof(link.ll));
if (r < 0)
n = sendto(fd, &arp, sizeof(struct ether_arp), 0, &link.sa, sizeof(link.ll));
if (n < 0)
return -errno;
if (n != sizeof(struct ether_arp))
return -EIO;
return 0;
}