Changeset 53afba12 in rtems
- Timestamp:
- Aug 6, 2009, 7:26:56 PM (11 years ago)
- Branches:
- 4.10, 4.11, 5, master
- Children:
- fba809c
- Parents:
- 288f8498
- Location:
- cpukit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/ChangeLog
r288f8498 r53afba12 1 2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com> 2 3 * posix/src/mqueuecreatesupp.c, posix/src/mqueuenametoid.c, 4 posix/src/mqueueopen.c, posix/src/semaphorecreatesupp.c: Tinker with 5 error handling for name too long. Use strnlen to ensure we do not run 6 off the end of the maximum length string. 7 1 8 2009-08-06 Christian Mauderer <christian.mauderer@embedded-brains.de> 2 9 -
cpukit/posix/src/mqueuecreatesupp.c
r288f8498 r53afba12 12 12 * time. 13 13 * 14 * COPYRIGHT (c) 1989-200 7.14 * COPYRIGHT (c) 1989-2009. 15 15 * On-Line Applications Research Corporation (OAR). 16 16 * … … 68 68 69 69 n = strnlen( name_arg, NAME_MAX ); 70 if ( n > NAME_MAX ) 71 return ENAMETOOLONG; 70 /* length of name has already been validated */ 72 71 73 72 _Thread_Disable_dispatch(); … … 79 78 * think will print out the defaults. Report anything you find with it. 80 79 */ 81 82 80 if ( attr_ptr == NULL ) { 83 81 attr.mq_maxmsg = 10; … … 112 110 * dynamically constructed. 113 111 */ 114 115 name = _Workspace_Allocate(n); 112 name = _Workspace_Allocate(n+1); 116 113 if (!name) { 117 114 _POSIX_Message_queue_Free( the_mq ); … … 119 116 rtems_set_errno_and_return_minus_one( ENOMEM ); 120 117 } 121 str cpy( name, name_arg);118 strncpy( name, name_arg, n+1 ); 122 119 123 /* XXX 120 /* 121 * NOTE: That thread blocking discipline should be based on the 122 * current scheduling policy. 124 123 * 125 * Note that thread blocking discipline should be based on the126 * current scheduling policy.124 * Joel: Cite POSIX or OpenGroup on above statement so we can determine 125 * if it is a real requirement. 127 126 */ 128 129 127 the_mq_attr = &the_mq->Message_queue.Attributes; 130 128 the_mq_attr->discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO; 131 129 132 if ( ! 130 if ( !_CORE_message_queue_Initialize( 133 131 &the_mq->Message_queue, 134 132 the_mq_attr, -
cpukit/posix/src/mqueuenametoid.c
r288f8498 r53afba12 1 1 /* 2 * NOTE: The structure of the routines is identical to that of POSIX 3 * Message_queues to leave the option of having unnamed message 4 * queues at a future date. They are currently not part of the 5 * POSIX standard but unnamed message_queues are. This is also 6 * the reason for the apparently unnecessary tracking of 7 * the process_shared attribute. [In addition to the fact that 8 * it would be trivial to add pshared to the mq_attr structure 9 * and have process private message queues.] 10 * 11 * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open 12 * time. 13 * 14 * COPYRIGHT (c) 1989-2007. 2 * COPYRIGHT (c) 1989-2009. 15 3 * On-Line Applications Research Corporation (OAR). 16 4 * … … 40 28 #include <rtems/posix/time.h> 41 29 42 /*PAGE 43 * 30 /* pure ANSI mode does not have this prototype */ 31 size_t strnlen(const char *, size_t); 32 33 /* 44 34 * _POSIX_Message_queue_Name_to_id 45 35 * … … 47 37 * for the associated message queue. 48 38 */ 49 50 39 int _POSIX_Message_queue_Name_to_id( 51 40 const char *name, … … 62 51 return EINVAL; 63 52 64 if ( strlen(name) > PATH_MAX )53 if ( strnlen( name, NAME_MAX ) >= NAME_MAX ) 65 54 return ENAMETOOLONG; 66 55 -
cpukit/posix/src/mqueueopen.c
r288f8498 r53afba12 12 12 * time. 13 13 * 14 * COPYRIGHT (c) 1989-200 7.14 * COPYRIGHT (c) 1989-2009. 15 15 * On-Line Applications Research Corporation (OAR). 16 16 * … … 40 40 #include <rtems/posix/time.h> 41 41 42 /*PAGE 43 * 42 /* 44 43 * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272 45 44 */ 46 47 45 mqd_t mq_open( 48 46 const char *name, … … 86 84 * or some other miscellaneous error on the name. 87 85 */ 88 89 86 if ( status ) { 90 91 87 /* 92 88 * Unless provided a valid name that did not already exist 93 89 * and we are willing to create then it is an error. 94 90 */ 95 96 91 if ( !( status == ENOENT && (oflag & O_CREAT) ) ) { 97 92 _POSIX_Message_queue_Free_fd( the_mq_fd ); … … 101 96 102 97 } else { /* name -> ID translation succeeded */ 103 104 98 /* 105 99 * Check for existence with creation. 106 100 */ 107 108 101 if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { 109 102 _POSIX_Message_queue_Free_fd( the_mq_fd ); … … 116 109 * check the mode. 117 110 */ 118 119 111 the_mq = _POSIX_Message_queue_Get( the_mq_id, &location ); 120 112 the_mq->open_count += 1; … … 135 127 * checked. We should go ahead and create a message queue. 136 128 */ 137 138 129 status = _POSIX_Message_queue_Create_support( 139 130 name, … … 146 137 * errno was set by Create_support, so don't set it again. 147 138 */ 148 149 139 if ( status == -1 ) { 140 _POSIX_Message_queue_Free_fd( the_mq_fd ); 150 141 _Thread_Enable_dispatch(); 151 _POSIX_Message_queue_Free_fd( the_mq_fd );152 142 return (mqd_t) -1; 153 143 } -
cpukit/posix/src/semaphorecreatesupp.c
r288f8498 r53afba12 1 1 /* 2 * COPYRIGHT (c) 1989-200 7.2 * COPYRIGHT (c) 1989-2009. 3 3 * On-Line Applications Research Corporation (OAR). 4 4 * … … 29 29 #include <rtems/seterr.h> 30 30 31 /*PAGE 32 * 31 /* pure ANSI mode does not have this prototype */ 32 size_t strnlen(const char *, size_t); 33 34 /* 33 35 * _POSIX_Semaphore_Create_support 34 36 * … … 37 39 * sem_open. 38 40 */ 39 40 41 int _POSIX_Semaphore_Create_support( 41 42 const char *name, … … 49 50 char *name_p = (char *)name; 50 51 51 _Thread_Disable_dispatch(); 52 /* Sharing semaphores among processes is not currently supported */ 53 if (pshared != 0) 54 rtems_set_errno_and_return_minus_one( ENOSYS ); 52 55 53 /* Sharing semaphores among processes is not currently supported */ 54 if (pshared != 0) { 55 _Thread_Enable_dispatch(); 56 rtems_set_errno_and_return_minus_one( ENOSYS ); 56 if ( name ) { 57 if ( strnlen( name, NAME_MAX ) >= NAME_MAX ) 58 rtems_set_errno_and_return_minus_one( ENAMETOOLONG ); 57 59 } 58 60 59 if ( name ) { 60 if( strlen(name) > PATH_MAX ) { 61 _Thread_Enable_dispatch(); 62 rtems_set_errno_and_return_minus_one( ENAMETOOLONG ); 63 } 64 } 61 _Thread_Disable_dispatch(); 65 62 66 63 the_semaphore = _POSIX_Semaphore_Allocate(); … … 92 89 * the same as all other POSIX implementations. :) 93 90 */ 94 95 91 the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; 96 92 … … 98 94 * This effectively disables limit checking. 99 95 */ 100 101 96 the_sem_attr->maximum_count = 0xFFFFFFFF; 102 97 … … 106 101 * Make the semaphore available for use. 107 102 */ 108 109 103 _Objects_Open_string( 110 104 &_POSIX_Semaphore_Information,
Note: See TracChangeset
for help on using the changeset viewer.