If the signature on an icmp echo reply doesn't match, don't count it as
authorjmatthew <jmatthew@openbsd.org>
Mon, 21 Feb 2022 03:50:46 +0000 (03:50 +0000)
committerjmatthew <jmatthew@openbsd.org>
Mon, 21 Feb 2022 03:50:46 +0000 (03:50 +0000)
a reply we've received, and print out the source address and sequence number
as that might help the user understand what's going on.

ok florian@ dlg@

sbin/ping/ping.c

index 6fa634b..fb31365 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ping.c,v 1.245 2021/07/12 15:09:19 beck Exp $ */
+/*     $OpenBSD: ping.c,v 1.246 2022/02/21 03:50:46 jmatthew Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -1302,7 +1302,10 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr)
 
                        if (timingsafe_memcmp(mac, &payload.mac,
                            sizeof(mac)) != 0) {
-                               printf("signature mismatch!\n");
+                               printf("signature mismatch from %s: "
+                                   "icmp_seq=%u\n", pr_addr(from, fromlen),
+                                   ntohs(seq));
+                               --nreceived;
                                return;
                        }
                        timinginfo=1;