commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd,commited 1/3] hurd: fix usleep(ULONG_MAX)


From: Samuel Thibault
Subject: [hurd,commited 1/3] hurd: fix usleep(ULONG_MAX)
Date: Mon, 29 Jun 2020 02:32:16 +0200

* sysdeps/mach/usleep.c (usleep): Clamp timeout when rouding up.
---
 sysdeps/mach/usleep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sysdeps/mach/usleep.c b/sysdeps/mach/usleep.c
index 530336ba0b..d53eb04a51 100644
--- a/sysdeps/mach/usleep.c
+++ b/sysdeps/mach/usleep.c
@@ -25,11 +25,15 @@ int
 usleep (useconds_t useconds)
 {
   mach_port_t recv;
+  useconds_t useconds_up = useconds + 999;
+
+  if (useconds_up < useconds)
+    useconds_up = UINT32_MAX;
 
   recv = __mach_reply_port ();
 
   (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
-                    0, 0, recv, (useconds + 999) / 1000, MACH_PORT_NULL);
+                    0, 0, recv, useconds_up / 1000, MACH_PORT_NULL);
   __mach_port_destroy (mach_task_self (), recv);
 
   return 0;
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]