chiark / gitweb /
pathmtu/pathmtu.c (raw): Check the UDP packet signature.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 19 Sep 2017 09:02:25 +0000 (10:02 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 28 Jun 2018 23:25:20 +0000 (00:25 +0100)
pathmtu/pathmtu.c

index 6d988031c474a520fcc0b7b57f6886fe3854b55b..f42602e03bce709391ff7765b5fa7fab8c640d01 100644 (file)
@@ -533,6 +533,7 @@ static int raw_selproc(void *stv, fd_set *fd_in, struct probestate *ps)
   struct ip *ip;
   struct icmp *icmp;
   struct udphdr *udp;
+  const unsigned char *payload;
   ssize_t n;
 
   /* An ICMP packet: see what's inside. */
@@ -565,6 +566,9 @@ static int raw_selproc(void *stv, fd_set *fd_in, struct probestate *ps)
       goto skip_icmp;
     n -= sizeof(*udp);
 
+    payload = (const unsigned char *)(udp + 1);
+    if (!mypacketp(ps, payload, n)) goto skip_icmp;
+
     if (icmp->icmp_code == ICMP_UNREACH_PORT) return (RC_HIGHER);
     else if (icmp->icmp_code != ICMP_UNREACH_NEEDFRAG) goto skip_icmp;
     else if (icmp->icmp_nextmtu) return (htons(icmp->icmp_nextmtu));