[Bug libc/10129] Add the invalid attr checking for pthread_mutexattr_gettype()
zhangxiliang at cn dot fujitsu dot com
sourceware-bugzilla@sourceware.org
Wed May 6 01:43:00 GMT 2009
------- 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.
More information about the Glibc-bugs
mailing list