While running ping6 to my own IP address I got an error message. This
was because pselect () threw an EINVAL error.

This was a mistake in my previous change. I thought a condition was part
of the subtraction of two timevals. But it was separate and intended to
check if the timeval was negative before calling select ().

I've pushed the attached patch fixing it.

Collin

>From 183f8d940ffcf5a308aa96c731c1a80a580aa653 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 29 Jun 2024 17:48:35 -0700
Subject: [PATCH] ping, ping6: Fix mistake in previous change.

* ping/ping.c (ping_run): Set the timespec to zero if it is negative
before calling pselect.
* ping/ping6.c (ping_run): Likewise.
---
 ping/ping.c  | 3 +++
 ping/ping6.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/ping/ping.c b/ping/ping.c
index 1f2f6702..f4a49342 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -421,6 +421,9 @@ ping_run (PING *ping, int (*finish) (void))
       now = current_timespec ();
       resp_time = timespec_sub (timespec_add (last, intvl), now);
 
+      if (timespec_sign (resp_time) == -1)
+	resp_time.tv_sec = resp_time.tv_nsec = 0;
+
       n = pselect (fdmax, &fdset, NULL, NULL, &resp_time, NULL);
       if (n < 0)
 	{
diff --git a/ping/ping6.c b/ping/ping6.c
index 2ac47aa0..0aa2819e 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -365,6 +365,9 @@ ping_run (PING *ping, int (*finish) (void))
       now = current_timespec ();
       resp_time = timespec_sub (timespec_add (last, intvl), now);
 
+      if (timespec_sign (resp_time) == -1)
+	resp_time.tv_sec = resp_time.tv_nsec = 0;
+
       n = pselect (fdmax, &fdset, NULL, NULL, &resp_time, NULL);
       if (n < 0)
 	{
-- 
2.45.2

  • ping, ping6... Collin Funk
    • Re: pi... Erik Auerswald
      • Re... Collin Funk
        • ... Erik Auerswald
          • ... Simon Josefsson via Bug reports for the GNU Internet utilities
            • ... Erik Auerswald
              • ... Simon Josefsson via Bug reports for the GNU Internet utilities
              • ... Simon Josefsson via Bug reports for the GNU Internet utilities
                • ... Collin Funk

Reply via email to