summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/semaphorecreatesupp.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-06 19:26:56 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-06 19:26:56 +0000
commit53afba1268c9ec94f35d9692a49204ab7ff3e367 (patch)
tree5a68306b034d2216778da5930a0874be367a71a8 /cpukit/posix/src/semaphorecreatesupp.c
parent2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-53afba1268c9ec94f35d9692a49204ab7ff3e367.tar.bz2
2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com>
* posix/src/mqueuecreatesupp.c, posix/src/mqueuenametoid.c, posix/src/mqueueopen.c, posix/src/semaphorecreatesupp.c: Tinker with error handling for name too long. Use strnlen to ensure we do not run off the end of the maximum length string.
Diffstat (limited to 'cpukit/posix/src/semaphorecreatesupp.c')
-rw-r--r--cpukit/posix/src/semaphorecreatesupp.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c
index da4050024c..42e530bf07 100644
--- a/cpukit/posix/src/semaphorecreatesupp.c
+++ b/cpukit/posix/src/semaphorecreatesupp.c
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -28,15 +28,16 @@
#include <rtems/posix/time.h>
#include <rtems/seterr.h>
-/*PAGE
- *
+/* pure ANSI mode does not have this prototype */
+size_t strnlen(const char *, size_t);
+
+/*
* _POSIX_Semaphore_Create_support
*
* This routine does the actual creation and initialization of
* a poxix semaphore. It is a support routine for sem_init and
* sem_open.
*/
-
int _POSIX_Semaphore_Create_support(
const char *name,
int pshared,
@@ -48,21 +49,17 @@ int _POSIX_Semaphore_Create_support(
CORE_semaphore_Attributes *the_sem_attr;
char *name_p = (char *)name;
- _Thread_Disable_dispatch();
-
/* Sharing semaphores among processes is not currently supported */
- if (pshared != 0) {
- _Thread_Enable_dispatch();
+ if (pshared != 0)
rtems_set_errno_and_return_minus_one( ENOSYS );
- }
if ( name ) {
- if( strlen(name) > PATH_MAX ) {
- _Thread_Enable_dispatch();
+ if ( strnlen( name, NAME_MAX ) >= NAME_MAX )
rtems_set_errno_and_return_minus_one( ENAMETOOLONG );
- }
}
+ _Thread_Disable_dispatch();
+
the_semaphore = _POSIX_Semaphore_Allocate();
if ( !the_semaphore ) {
@@ -91,13 +88,11 @@ int _POSIX_Semaphore_Create_support(
* thing is certain, no matter what we decide, it won't be
* the same as all other POSIX implementations. :)
*/
-
the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
/*
* This effectively disables limit checking.
*/
-
the_sem_attr->maximum_count = 0xFFFFFFFF;
_CORE_semaphore_Initialize( &the_semaphore->Semaphore, the_sem_attr, value );
@@ -105,7 +100,6 @@ int _POSIX_Semaphore_Create_support(
/*
* Make the semaphore available for use.
*/
-
_Objects_Open_string(
&_POSIX_Semaphore_Information,
&the_semaphore->Object,