This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] generic version of pthread_cond_timedwait


Hi all,

I found a small error while looking at the code of routine:   
	nptl/sysdeps/pthread/pthread_cond_timedwait.c


At line 53, the function will reject values which are bigger than a
billion, but will accept negative values for the nanosecond member.

It appears that the too big values are not a problem, as they will be
filtered by the loop on line 129 (after the operation rt = abstime - tv)

On the other hand, a negative tv.tv_nsec value will result in a possibly
invalid ( > 10^9 ) rt.tv_nsec value passed to the kernel. With the
current code the kernel accepts such a value but I think one should not
rely on this.

I also looked at the i486 version of the function, and in this case no
check is done at all. Do you consider there is no use for returning an
error when an user has made a bug? Or is it a miss?

Best regards,
Sebastien.

PS: I attached a patch but I don't know the correct formatting -- and I
don't expect this patch to be applyed as is anyway.

-------------------------------
Sebastien DECUGIS
NPTL Test & Trace Project
http://nptl.bullopensource.org/

diff -Nur libc/nptl/sysdeps/pthread/pthread_cond_timedwait.c libc-new/nptl/sysdeps/pthread/pthread_cond_timedwait.c
--- libc/nptl/sysdeps/pthread/pthread_cond_timedwait.c	2004-06-17 18:02:17.113582088 +0200
+++ libc-new/nptl/sysdeps/pthread/pthread_cond_timedwait.c	2004-06-17 18:02:53.000126504 +0200
@@ -50,7 +50,7 @@
   int result = 0;
 
   /* Catch invalid parameters.  */
-  if (abstime->tv_nsec >= 1000000000)
+  if (abstime->tv_nsec < 0)
     return EINVAL;
 
   /* Make sure we are along.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]