[Patch] Fix ping accepting only same sized packets
Миша Завёрткин
misha.zavertkin at mail.ru
Wed Apr 17 10:34:52 UTC 2024
Now ping expects response packets same size as sent. But 8.8.8.8 limit packet size. This makes «ping -s 89 8.8.8.8» to fail
The patch removes datalen from discarding short packages and makes calculating header length correct
diff --git a/networking/ping.c b/networking/ping.c
index b7e6955a9..ecf9c569e 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -696,7 +696,7 @@ static int unpack4(char *buf, int sz, struct sockaddr_in *from)
int hlen;
/* discard if too short */
- if (sz < (datalen + ICMP_MINLEN))
+ if (sz < (sizeof(struct iphdr) + ICMP_MINLEN))
return 0;
/* check IP header */
@@ -732,7 +732,7 @@ static int unpack6(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit
char buf[INET6_ADDRSTRLEN];
/* discard if too short */
- if (sz < (datalen + sizeof(struct icmp6_hdr)))
+ if (sz < sizeof(struct icmp6_hdr))
return 0;
icmppkt = (struct icmp6_hdr *) packet;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20240417/d97e6923/attachment.html>
More information about the busybox
mailing list