summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mqueuecreatesupp.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2004-02-26 14:28:56 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2004-02-26 14:28:56 +0000
commit652524d9538f50e229349314043cedb5a15f18be (patch)
tree93349fee27a1ad4c10f260ac9d5e34f3a335530a /cpukit/posix/src/mqueuecreatesupp.c
parent2004-02-26 Sébastien Barré <sbarre@sdelcc.com> (diff)
downloadrtems-652524d9538f50e229349314043cedb5a15f18be.tar.bz2
2004-02-26 Joel Sherrill <joel@OARcorp.com>
PR 582/core * posix/src/mqueue.c, posix/src/mqueuecreatesupp.c, posix/src/mqueuedeletesupp.c, posix/src/mqueueunlink.c: Use memory from workspace to avoid use of mutex during dispatch disable critical section. Besides memory for object names should come from the Workspace anyway.
Diffstat (limited to 'cpukit/posix/src/mqueuecreatesupp.c')
-rw-r--r--cpukit/posix/src/mqueuecreatesupp.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/cpukit/posix/src/mqueuecreatesupp.c b/cpukit/posix/src/mqueuecreatesupp.c
index 1e0aa6f57d..091da0de87 100644
--- a/cpukit/posix/src/mqueuecreatesupp.c
+++ b/cpukit/posix/src/mqueuecreatesupp.c
@@ -18,6 +18,7 @@
#include "config.h"
#endif
+#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -29,10 +30,14 @@
#include <rtems/system.h>
#include <rtems/score/watchdog.h>
+#include <rtems/score/wkspace.h>
#include <rtems/seterr.h>
#include <rtems/posix/mqueue.h>
#include <rtems/posix/time.h>
+/* pure ANSI mode does not have this prototype */
+size_t strnlen(const char *, size_t);
+
/*PAGE
*
* _POSIX_Message_queue_Create_support
@@ -42,7 +47,7 @@
*/
int _POSIX_Message_queue_Create_support(
- const char *_name,
+ const char *name_arg,
int pshared,
struct mq_attr *attr_ptr,
POSIX_Message_queue_Control **message_queue
@@ -51,7 +56,12 @@ int _POSIX_Message_queue_Create_support(
POSIX_Message_queue_Control *the_mq;
CORE_message_queue_Attributes *the_mq_attr;
struct mq_attr attr;
- char *name;
+ char *name;
+ size_t n;
+
+ n = strnlen( name_arg, NAME_MAX );
+ if ( n > NAME_MAX )
+ return ENAMETOOLONG;
_Thread_Disable_dispatch();
@@ -100,6 +110,18 @@ int _POSIX_Message_queue_Create_support(
the_mq->open_count = 1;
the_mq->linked = TRUE;
+ /*
+ * Make a copy of the user's string for name just in case it was
+ * dynamically constructed.
+ */
+
+ name = _Workspace_Allocate(n);
+ if (!name) {
+ _POSIX_Message_queue_Free( the_mq );
+ _Thread_Enable_dispatch();
+ rtems_set_errno_and_return_minus_one( ENOMEM );
+ }
+ strcpy( name, name_arg );
/* XXX
*
@@ -123,12 +145,11 @@ int _POSIX_Message_queue_Create_support(
#endif
_POSIX_Message_queue_Free( the_mq );
+ _Workspace_Free(name);
_Thread_Enable_dispatch();
rtems_set_errno_and_return_minus_one( ENOSPC );
}
- name = malloc(256);
- strcpy( name, _name );
_Objects_Open(
&_POSIX_Message_queue_Information,
&the_mq->Object,