projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
42976ce
)
report sem value overflows in sem_post
author
Rich Felker
<dalias@aerifal.cx>
Wed, 26 Oct 2011 04:28:47 +0000
(
00:28
-0400)
committer
Rich Felker
<dalias@aerifal.cx>
Wed, 26 Oct 2011 04:28:47 +0000
(
00:28
-0400)
this is not required by the standard, but it's nicer than corrupting
the state and rather inexpensive.
src/thread/sem_post.c
patch
|
blob
|
history
diff --git
a/src/thread/sem_post.c
b/src/thread/sem_post.c
index 148ab780e8f94d04ac2a0e222ff1f8631096708a..14a2dfe23ca09290db575f4c5b27e4c31e1eff24 100644
(file)
--- a/
src/thread/sem_post.c
+++ b/
src/thread/sem_post.c
@@
-7,6
+7,10
@@
int sem_post(sem_t *sem)
do {
val = sem->__val[0];
waiters = sem->__val[1];
+ if (val == SEM_VALUE_MAX) {
+ errno = EOVERFLOW;
+ return -1;
+ }
} while (a_cas(sem->__val, val, val+1+(val<0)) != val);
if (val<0 || waiters) __wake(sem->__val, 1, 0);
return 0;