4.104.115
Last change
on this file since 53afba12 was
53afba12,
checked in by Joel Sherrill <joel.sherrill@…>, on 08/06/09 at 19:26:56
|
2009-08-06 Joel Sherrill <joel.sherrill@…>
- 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.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <stdarg.h> |
---|
17 | |
---|
18 | #include <pthread.h> |
---|
19 | #include <limits.h> |
---|
20 | #include <errno.h> |
---|
21 | #include <fcntl.h> |
---|
22 | #include <mqueue.h> |
---|
23 | |
---|
24 | #include <rtems/system.h> |
---|
25 | #include <rtems/score/watchdog.h> |
---|
26 | #include <rtems/seterr.h> |
---|
27 | #include <rtems/posix/mqueue.h> |
---|
28 | #include <rtems/posix/time.h> |
---|
29 | |
---|
30 | /* pure ANSI mode does not have this prototype */ |
---|
31 | size_t strnlen(const char *, size_t); |
---|
32 | |
---|
33 | /* |
---|
34 | * _POSIX_Message_queue_Name_to_id |
---|
35 | * |
---|
36 | * Look up the specified name and attempt to locate the id |
---|
37 | * for the associated message queue. |
---|
38 | */ |
---|
39 | int _POSIX_Message_queue_Name_to_id( |
---|
40 | const char *name, |
---|
41 | Objects_Id *id |
---|
42 | ) |
---|
43 | { |
---|
44 | Objects_Name_or_id_lookup_errors status; |
---|
45 | Objects_Id the_id; |
---|
46 | |
---|
47 | if ( !name ) |
---|
48 | return EINVAL; |
---|
49 | |
---|
50 | if ( !name[0] ) |
---|
51 | return EINVAL; |
---|
52 | |
---|
53 | if ( strnlen( name, NAME_MAX ) >= NAME_MAX ) |
---|
54 | return ENAMETOOLONG; |
---|
55 | |
---|
56 | status = _Objects_Name_to_id_string( |
---|
57 | &_POSIX_Message_queue_Information, |
---|
58 | name, |
---|
59 | &the_id |
---|
60 | ); |
---|
61 | *id = the_id; |
---|
62 | |
---|
63 | if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) |
---|
64 | return 0; |
---|
65 | |
---|
66 | return ENOENT; |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.