This is the mail archive of the glibc-bugs@sourceware.org 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]

[Bug libc/10129] New: Add the invalid attr checking for pthread_mutexattr_gettype()


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.


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