]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
arp-util: check sent message size
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Jun 2021 06:17:11 +0000 (15:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Jun 2021 15:49:02 +0000 (00:49 +0900)
src/libsystemd-network/arp-util.c

index 3c04a86e89c5f1bbb35466c9c8ac2bf9daa00890..d17ae1be04b541fc8eba9a5722a27a4488ec9032 100644 (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;
 }