summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mqueueopen.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/mqueueopen.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/mqueueopen.c')
-rw-r--r--cpukit/posix/src/mqueueopen.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/cpukit/posix/src/mqueueopen.c b/cpukit/posix/src/mqueueopen.c
index 02d1b08e5e..2b96236fb5 100644
--- a/cpukit/posix/src/mqueueopen.c
+++ b/cpukit/posix/src/mqueueopen.c
@@ -11,7 +11,7 @@
* This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
* time.
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -39,11 +39,9 @@
#include <rtems/posix/mqueue.h>
#include <rtems/posix/time.h>
-/*PAGE
- *
+/*
* 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272
*/
-
mqd_t mq_open(
const char *name,
int oflag,
@@ -85,14 +83,11 @@ mqd_t mq_open(
* need to check to see if this is a "message queue does not exist"
* or some other miscellaneous error on the name.
*/
-
if ( status ) {
-
/*
* Unless provided a valid name that did not already exist
* and we are willing to create then it is an error.
*/
-
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
_POSIX_Message_queue_Free_fd( the_mq_fd );
_Thread_Enable_dispatch();
@@ -100,11 +95,9 @@ mqd_t mq_open(
}
} else { /* name -> ID translation succeeded */
-
/*
* Check for existence with creation.
*/
-
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
_POSIX_Message_queue_Free_fd( the_mq_fd );
_Thread_Enable_dispatch();
@@ -115,7 +108,6 @@ mqd_t mq_open(
* In this case we need to do an ID->pointer conversion to
* check the mode.
*/
-
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
the_mq->open_count += 1;
the_mq_fd->Queue = the_mq;
@@ -134,7 +126,6 @@ mqd_t mq_open(
* At this point, the message queue does not exist and everything has been
* checked. We should go ahead and create a message queue.
*/
-
status = _POSIX_Message_queue_Create_support(
name,
true, /* shared across processes */
@@ -145,10 +136,9 @@ mqd_t mq_open(
/*
* errno was set by Create_support, so don't set it again.
*/
-
if ( status == -1 ) {
- _Thread_Enable_dispatch();
_POSIX_Message_queue_Free_fd( the_mq_fd );
+ _Thread_Enable_dispatch();
return (mqd_t) -1;
}