Menu

#378 tau_tti: Static vehicle properties written out of memory

3.0.0.0
closed
2024-02-05
2021-10-06
No

In tau_tti.c function ttiCreateCstInfoEntry

vehProp.prop from the received telegram is copied to an array of fixed size 1. Then length info is not considered and memory are not allocated.

This line cause the problem.
memcpy(pDest->pVehInfoList[idx].vehProp.prop, pData, pDest->pVehInfoList[idx].vehProp.len);

/ Application defined properties */
typedef struct
{
TRDP_SHORT_VERSION_T ver; /
< properties version information, application defined /
UINT16 len; /
< properties length in number of octets,
application defined, must be a multiple
of 4 octets for alignment reasons
value range: 0..32768
/
UINT8 prop[1]; /*< properties, application defined /
} TRDP_PROP_T;

Suggested solutions:
Change the defined size of prop to 32768 (Max value defined in IEC_61375-2-3_2015)
or
Change to a pointer and dynamically allocate the required memory from the length property.

Discussion

  • Armin-Hagen Weiss

    • status: open --> accepted
    • assigned_to: Armin-Hagen Weiss
    • Milestone: 2.1.0.0 --> 2.2.0.0
     
  • Armin-Hagen Weiss

    • labels: --> 2311
    • status: accepted --> pending
    • assigned_to: Armin-Hagen Weiss --> Anders Öberg
     
  • Armin-Hagen Weiss

    Now for properties dynamic memory is allocated. ATTENTION: TRDP_VEHICLE_INFO_T and TRDP_CONSIST_INFO_T containing now a pointer to TRDP_PROP_T not anymore TRDP_PROP_T itself. To be tested.

     
  • Armin-Hagen Weiss

    • summary: Static vehicle properties written out of memory --> tau_tti: Static vehicle properties written out of memory
     
  • Anders Öberg

    Anders Öberg - 2021-10-11
     
  • Anders Öberg

    Anders Öberg - 2021-10-11

    Tested
    Bug fixes committed in #2314
    Test OK

     
  • Anders Öberg

    Anders Öberg - 2021-10-11

    Update #2316
    Don't crate memory for properties if len = 0. And never access it.

    Test OK

     
  • Armin-Hagen Weiss

    • labels: 2311 --> 2311, 2312, 2314, 2315, 2316
    • status: pending --> closed
     
  • Armin-Hagen Weiss

    Memory for properties cstProp and vehProp dynamically allocated if len > 0. If len == 0, pxxxProp = NULL.

     

Log in to post a comment.

MongoDB Logo MongoDB