Menu

#253 Incorrect storing of TTDB_STATIC_CONSIST_INFO_REPLY from network packet into local copy

1.4.2.0
closed
None
2019-06-14
2019-05-02
No

On receiving the TTDB_STATIC_CONSIST_INFO_REPLY (ComId 105), the data is to be converted to local representation and stored into the local copy.

The structure used for storing it locally is as follows:

/** consist information structure */
typedef struct
{
    TRDP_SHORT_VERSION_T    version;        /**< ConsistInfo data structure version, application defined
                                                 mainVersion = 1, subVersion = 0                         */
    UINT8                   cstClass;       /**< consist info classification
                                                 1 = (single) consist
                                                 2 = closed train
                                                 3 = closed train consist */
    UINT8                   reserved01;     /**< reserved for future use (= 0) */
    TRDP_NET_LABEL_T        cstId;          /**< application defined consist identifier, e.g. UIC identifier */
    TRDP_NET_LABEL_T        cstType;        /**< consist type, application defined */
    TRDP_NET_LABEL_T        cstOwner;       /**< consist owner, e.g. "trenitalia.it", "sncf.fr", "db.de" */
    TRDP_UUID_T             cstUUID;        /**< consist UUID  */
    UINT32                  reserved02;     /**< reserved for future use (= 0) */
    TRDP_PROP_T             cstProp;        /**< static consist properties */
    UINT16                  reserved03;     /**< reserved for future use (= 0) */
    UINT16                  etbCnt;         /**< number of ETB's, range: 1..4 */
    TRDP_ETB_INFO_T        *pEtbInfoList;   /**< ETB information list for the consist
                                                 Ordered list starting with lowest etbId */
    UINT16                  reserved04;     /**< reserved for future use (= 0) */
    UINT16                  vehCnt;         /**< number of vehicles in consist 1..32 */
    TRDP_VEHICLE_INFO_T    *pVehInfoList;   /**< vehicle info list for the vehicles in the consist 
                                                 Ordered list starting with cstVehNo==1 */
    UINT16                  reserved05;     /**< reserved for future use (= 0) */
    UINT16                  fctCnt;         /**< number of consist functions
                                                 value range 0..1024 */
    TRDP_FUNCTION_INFO_T   *pFctInfoList;   /**< function info list for the functions in consist
                                                 lexicographical ordered by fctName */
    UINT16                  reserved06;     /**< reserved for future use (= 0) */
    UINT16                  cltrCstCnt;     /**< number of original consists in closed train 
                                                 value range: 0..32, 0 = consist is no closed train */
    TRDP_CLTR_CST_INFO_T   *pCltrCstInfoList; 
                                            /**< info on closed train composition
                                                 Ordered list starting with cltrCstNo == 1 */
    UINT32                  cstTopoCnt;      /**< consist topology counter computed as defined in 5.3.3.2.16, 
                                                 seed value: 'FFFFFFFF'H */
} TRDP_CONSIST_INFO_T;

In function ttiStoreCstInfo(), the complete data received in packet comId 105 is directly copied into local structure TRDP_CONSIST_INFO_T. This will not work, as this structure has pointers stored instead of static memory arrays for variables like EtbInfoList, VehInfoList, FctInfoList, CltrCstInfoList. Also the static consist and vehicle properties are not stored properly in structure TRDP_PROP_T. (it has static memory of size 1 byte regardless of the length.)

Also, the endianness is to be converted for various counts inside.

Maintaining a fully static memory for the complete TRDP_CONSIST_INFO_T would be easier, but would utilize a lot of space as the max size would be pretty large.

Propose to handle the static consist info local storage correctly through dynamic memory.

Discussion

  • Chirag Khangani

    Chirag Khangani - 2019-05-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -On receiving the TTDB_STATIC_CONSIST_INFO_REPLY  (ComId 10), the data is to be converted to local representation and stored into the local copy.
    +On receiving the TTDB_STATIC_CONSIST_INFO_REPLY  (ComId 105), the data is to be converted to local representation and stored into the local copy.
    
     The structure used for storing it locally is as follows:
    
     
  • Bernd Löhr

    Bernd Löhr - 2019-05-14
    • status: open --> accepted
    • assigned_to: Chirag Khangani --> Bernd Löhr
     
  • Bernd Löhr

    Bernd Löhr - 2019-05-14

    The TRDP_CONSIST_INFO_T is a variable sized struct/array and was locally stored in network (packed) form. When accessing via tau_getCstInfo(), the caller would receive a converted version. This was not correct. The code in ttiStoreCstInfo will now allocate and populate the typedef'd structure.

     
  • Bernd Löhr

    Bernd Löhr - 2019-06-11
    • status: accepted --> pending
     
  • Bernd Löhr

    Bernd Löhr - 2019-06-14
    • Status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB