[RTEMS Project] #2923: Questionable Code in resource_snapshot.c
RTEMS trac
trac at rtems.org
Fri Mar 10 18:13:20 UTC 2017
#2923: Questionable Code in resource_snapshot.c
---------------------------+-----------------------------
Reporter: Joel Sherrill | Owner: joel.sherrill@…
Type: defect | Status: new
Priority: normal | Milestone: 4.12
Component: cpukit | Version: 4.12
Severity: normal | Keywords:
---------------------------+-----------------------------
Coverity URL:
https://scan5.coverity.com/reports.htm#v29808/p10069/fileInstanceId=108958257&defectInstanceId=30877219&mergedDefectId=1399703
Coverity Scan doesn't like taking the address of a single uint32_t and
then treating it as an array pointer. I think the code is likely doing
what is intended but there is an implicit linkable between the order of
the fields in the structure here and the class numbers used in the object
IDs. Is there a way to improve this code and reduce the linkage?
141
1. address_of: Taking address with &snapshot->active_posix_keys
yields a singleton pointer.
2. assign: Assigning: active = &snapshot->active_posix_keys.
142 active = &snapshot->active_posix_keys;
143
3. Condition i < 19U /* sizeof (objects_info_table) / sizeof
(objects_info_table[0]) */, taking true branch.
144 for (i = 0; i < RTEMS_ARRAY_SIZE(objects_info_table); ++i) {
145 const Objects_Information *information;
146
147 information = _Objects_Get_information(
148 objects_info_table[i].api,
149 objects_info_table[i].cls
150 );
151
4. Condition information != NULL, taking true branch.
152 if (information != NULL) {
CID 1399703 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)
5. ptr_arith: Using active as an array. This might corrupt or misinterpret
adjacent memory locations.
153 active[i] = _Objects_Active_count(information);
--
Ticket URL: <http://devel.rtems.org/ticket/2923>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list