]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Handle NULL abstime [BZ #26394]
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 15 Aug 2020 18:06:35 +0000 (11:06 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 17 Aug 2020 12:02:06 +0000 (05:02 -0700)
Since abstime passed to pthread_{clock|timed}join_np may be NULL, convert
to 64 bit abstime only if abstime isn't NULL.

nptl/pthread_clockjoin.c
nptl/pthread_timedjoin.c

index 3cd780f68849374c8754b40719b678ee1c9ec231..0baba1e83d14a8641abe52450adc6daa1aaae6dd 100644 (file)
@@ -34,9 +34,15 @@ int
 __pthread_clockjoin_np (pthread_t threadid, void **thread_return,
                         clockid_t clockid, const struct timespec *abstime)
 {
-  struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
-
-  return __pthread_clockjoin_np64 (threadid, thread_return, clockid, &ts64);
+  if (abstime != NULL)
+    {
+      struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
+      return __pthread_clockjoin_np64 (threadid, thread_return, clockid,
+                                      &ts64);
+    }
+  else
+      return __pthread_clockjoin_np64 (threadid, thread_return, clockid,
+                                      NULL);
 }
 #endif
 weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np)
index 6164ae70601448f30c1c7a1695f09db5186feabc..6ade58853c9a0d27a5783c79ff4f0521d12da451 100644 (file)
@@ -34,9 +34,13 @@ int
 __pthread_timedjoin_np (pthread_t threadid, void **thread_return,
                         const struct timespec *abstime)
 {
-  struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
-
-  return __pthread_timedjoin_np64 (threadid, thread_return, &ts64);
+  if (abstime != NULL)
+    {
+      struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
+      return __pthread_timedjoin_np64 (threadid, thread_return, &ts64);
+    }
+  else
+    return __pthread_timedjoin_np64 (threadid, thread_return, NULL);
 }
 #endif
 weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np)