This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/10129] Add the invalid attr checking for pthread_mutexattr_gettype()
- From: "zhangxiliang at cn dot fujitsu dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 May 2009 01:43:20 -0000
- Subject: [Bug libc/10129] Add the invalid attr checking for pthread_mutexattr_gettype()
- References: <20090505021201.10129.zhangxiliang@cn.fujitsu.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From zhangxiliang at cn dot fujitsu dot com 2009-05-06 01:43 -------
(In reply to comment #1)
> Nonsense. If the value is stored it better be correct.
OK. I have make a corrected version.
Signed-off-by: Zhang Xiliang <zhangxiliang@cn.fujitsu.com>
---
nptl/pthread_mutexattr_gettype.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/nptl/pthread_mutexattr_gettype.c b/nptl/pthread_mutexattr_gettype.c
index 7303703..4da2dc1 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>
@@ -26,11 +27,15 @@ pthread_mutexattr_gettype (attr, kind)
int *kind;
{
const struct pthread_mutexattr *iattr;
+ int ikind;
iattr = (const struct pthread_mutexattr *) attr;
- *kind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+ ikind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+ if (ikind < PTHREAD_MUTEX_NORMAL || ikind > PTHREAD_MUTEX_ADAPTIVE_NP)
+ return EINVAL;
+ *kind = ikind;
return 0;
}
weak_alias (pthread_mutexattr_gettype, pthread_mutexattr_getkind_np)
--
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.