]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
OSSL_sleep(): Calling sleep() function if sleepTime > 1sec
authorRajarshi Karmakar <rkarmaka98@gmail.com>
Mon, 22 May 2023 16:51:57 +0000 (16:51 +0000)
committerTomas Mraz <tomas@openssl.org>
Tue, 30 May 2023 19:10:03 +0000 (21:10 +0200)
On some systems usleep() func does not support time >1sec.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21010)

crypto/sleep.c

index 95d6c7923351fc6f4e91de4dcb1cd975f5b16056..d57a9e3caa95491a9684a668b37201f0c0864331 100644 (file)
@@ -12,6 +12,7 @@
 
 /* system-specific variants defining OSSL_sleep() */
 #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
+#include <unistd.h>
 
 void OSSL_sleep(uint64_t millis)
 {
@@ -36,7 +37,11 @@ void OSSL_sleep(uint64_t millis)
     usleep(millis * 1000);
 #  endif
 # else
-    usleep(millis * 1000);
+    unsigned int s = (unsigned int)(millis / 1000);
+    unsigned int us = (unsigned int)((millis % 1000) * 1000);
+
+    sleep(s);
+    usleep(us);
 # endif
 }
 #elif defined(_WIN32) && !defined(OPENSSL_SYS_UEFI)