public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/10129] New: Add the invalid attr checking for pthread_mutexattr_gettype()
@ 2009-05-05  2:12 zhangxiliang at cn dot fujitsu dot com
  2009-05-05 14:50 ` [Bug libc/10129] " drepper at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zhangxiliang at cn dot fujitsu dot com @ 2009-05-05  2:12 UTC (permalink / raw)
  To: glibc-bugs

I tested the mutex type, and found that when I got a mutex type from an
invalid pthread_mutexattr by pthread_mutexattr_gettype(), the function
returns 0.

In pthread_mutexattr_gettype() manual, it directs that the function should
return EINVAL when the mutex type in struct pthread_mutexattr is invalid.

Signed-off-by: Zhang Xiliang <zhangxiliang@cn.fujitsu.com>
---
 nptl/pthread_mutexattr_gettype.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/nptl/pthread_mutexattr_gettype.c
b/nptl/pthread_mutexattr_gettype.c
index 7303703..40ed531 100644
--- a/nptl/pthread_mutexattr_gettype.c
+++ b/nptl/pthread_mutexattr_gettype.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */

+#include <errno.h>
 #include <pthreadP.h>


@@ -30,6 +31,8 @@ pthread_mutexattr_gettype (attr, kind)
   iattr = (const struct pthread_mutexattr *) attr;

   *kind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+  if (*kind < PTHREAD_MUTEX_NORMAL || *kind > PTHREAD_MUTEX_ADAPTIVE_NP)
+    return EINVAL;

   return 0;
 }

-- 
           Summary: Add the invalid attr checking for
                    pthread_mutexattr_gettype()
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: zhangxiliang at cn dot fujitsu dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10129

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-07 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-05  2:12 [Bug libc/10129] New: Add the invalid attr checking for pthread_mutexattr_gettype() zhangxiliang at cn dot fujitsu dot com
2009-05-05 14:50 ` [Bug libc/10129] " drepper at redhat dot com
2009-05-06  1:43 ` zhangxiliang at cn dot fujitsu dot com
2009-05-07 16:50 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).