summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-06-26 13:51:25 +0000
committerjhb <jhb@FreeBSD.org>2008-06-26 13:51:25 +0000
commited2c19947c0fe3e8fb2c15a829d3946d0eeb7c18 (patch)
tree4deb3ffb2f2d730885f715552cc617bbbf5c7e07
parentfd5bd912ed377b988835baf77ec4dbca60d10820 (diff)
downloadFreeBSD-src-ed2c19947c0fe3e8fb2c15a829d3946d0eeb7c18.zip
FreeBSD-src-ed2c19947c0fe3e8fb2c15a829d3946d0eeb7c18.tar.gz
Change SEM_VALUE_MAX (maximum value of a POSIX semaphore) from UINT_MAX
to INT_MAX. Otherwise, a process could create a semaphore (or increase its value via ksem_post()) beyond INT_MAX and sem_getvalue() would return a negative value. sem_getvalue() is only supposed to return a negative value if that is the number of waiters for that semaphore. MFC after: 2 weeks
-rw-r--r--sys/sys/semaphore.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/sys/semaphore.h b/sys/sys/semaphore.h
index 1806252..34ede7b 100644
--- a/sys/sys/semaphore.h
+++ b/sys/sys/semaphore.h
@@ -37,12 +37,14 @@
#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_
+#include <machine/_limits.h>
+
/* Opaque type definition. */
struct sem;
typedef struct sem * sem_t;
#define SEM_FAILED ((sem_t *)0)
-#define SEM_VALUE_MAX (~0U) /* Equivalent to UINT_MAX. */
+#define SEM_VALUE_MAX __INT_MAX
#ifndef _KERNEL
#include <sys/cdefs.h>
OpenPOWER on IntegriCloud