5
Last change
on this file since 0ab4fb7 was
0ab4fb7,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/03/16 at 07:12:51
|
score: Fix _Objects_Id_to_name()
Avoid out-of-bounds array access in case the object class is invalid.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Object id to name |
---|
5 | * @ingroup Score |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2003. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/threadimpl.h> |
---|
22 | |
---|
23 | Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( |
---|
24 | Objects_Id id, |
---|
25 | Objects_Name *name |
---|
26 | ) |
---|
27 | { |
---|
28 | Objects_Id tmpId; |
---|
29 | Objects_Information *information; |
---|
30 | Objects_Control *the_object = (Objects_Control *) 0; |
---|
31 | Objects_Locations ignored_location; |
---|
32 | ISR_lock_Context lock_context; |
---|
33 | |
---|
34 | /* |
---|
35 | * Caller is trusted for name != NULL. |
---|
36 | */ |
---|
37 | |
---|
38 | tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id; |
---|
39 | |
---|
40 | information = _Objects_Get_information_id( tmpId ); |
---|
41 | if ( !information ) |
---|
42 | return OBJECTS_INVALID_ID; |
---|
43 | |
---|
44 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
45 | if ( information->is_string ) |
---|
46 | return OBJECTS_INVALID_ID; |
---|
47 | #endif |
---|
48 | |
---|
49 | the_object = _Objects_Get_isr_disable( |
---|
50 | information, |
---|
51 | tmpId, |
---|
52 | &ignored_location, |
---|
53 | &lock_context |
---|
54 | ); |
---|
55 | if ( !the_object ) |
---|
56 | return OBJECTS_INVALID_ID; |
---|
57 | |
---|
58 | *name = the_object->name; |
---|
59 | _ISR_lock_ISR_enable( &lock_context ); |
---|
60 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.