FreeCalypso > hg > fc-magnetite
view cdg3/cdginc-conservative/p_mnsms.h @ 516:1ed9de6c90bd
src/g23m-gsm/sms/sms_for.c: bogus malloc removed
The new error handling code that was not present in TCS211 blob version
contains a malloc call that is bogus for 3 reasons:
1) The memory allocation in question is not needed in the first place;
2) libc malloc is used instead of one of the firmware's proper ways;
3) The memory allocation is made inside a function and then never freed,
i.e., a memory leak.
This bug was caught in gcc-built FreeCalypso fw projects (Citrine
and Selenite) because our gcc environment does not allow any use of
libc malloc (any reference to malloc produces a link failure),
but this code from TCS3.2 is wrong even for Magnetite: if this code
path is executed repeatedly over a long time, the many small allocations
made by this malloc call without a subsequent free will eventually
exhaust the malloc heap provided by the TMS470 environment, malloc will
start returning NULL, and the bogus code will treat it as an error.
Because the memory allocation in question is not needed at all,
the fix entails simply removing it.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 22 Jul 2018 06:04:49 +0000 |
parents | c15047b3d00d |
children |
line wrap: on
line source
/* +--------------------------------------------------------------------------+ | PROJECT : PROTOCOL STACK | | FILE : p_mnsms.h | | SOURCE : "sap\mnsms.pdf" | | LastModified : "2002-04-19" | | IdAndVersion : "6147.103.96.107" | | SrcFileTime : "Thu Nov 29 09:48:28 2007" | | Generated by CCDGEN_2.5.5A on Thu Sep 25 09:52:55 2014 | | !!DO NOT MODIFY!!DO NOT MODIFY!!DO NOT MODIFY!! | +--------------------------------------------------------------------------+ */ /* PRAGMAS * PREFIX : NONE * COMPATIBILITY_DEFINES : NO (require PREFIX) * ALWAYS_ENUM_IN_VAL_FILE: NO * ENABLE_GROUP: NO * CAPITALIZE_TYPENAME: NO */ #ifndef P_MNSMS_H #define P_MNSMS_H #define CDG_ENTER__P_MNSMS_H #define CDG_ENTER__FILENAME _P_MNSMS_H #define CDG_ENTER__P_MNSMS_H__FILE_TYPE CDGINC #define CDG_ENTER__P_MNSMS_H__LAST_MODIFIED _2002_04_19 #define CDG_ENTER__P_MNSMS_H__ID_AND_VERSION _6147_103_96_107 #define CDG_ENTER__P_MNSMS_H__SRC_FILE_TIME _Thu_Nov_29_09_48_28_2007 #include "CDG_ENTER.h" #undef CDG_ENTER__P_MNSMS_H #undef CDG_ENTER__FILENAME #include "p_mnsms.val" #include "m_sms.h" #ifndef __T_sms_sdu__ #define __T_sms_sdu__ /* * SIM-PDU * CCDGEN:WriteStruct_Count==1980 */ typedef struct { U16 l_buf; /*< 0: 2> command length */ U16 o_buf; /*< 2: 2> command offset */ U8 buf[SIM_PDU_LEN]; /*< 4:175> command data */ U8 _align0; /*<179: 1> alignment */ } T_sms_sdu; #endif /* * End of substructure section, begin of primitive definition section */ #ifndef __T_MNSMS_MESSAGE_IND__ #define __T_MNSMS_MESSAGE_IND__ /* * * CCDGEN:WriteStruct_Count==1981 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 rec_max; /*< 2: 1> maximum number of records (1..255) in EF(SMS) or other memory */ U8 status; /*< 3: 1> message status */ T_sms_sdu sms_sdu; /*< 4:180> SIM-PDU */ } T_MNSMS_MESSAGE_IND; #endif #ifndef __T_MNSMS_REPORT_IND__ #define __T_MNSMS_REPORT_IND__ /* * * CCDGEN:WriteStruct_Count==1982 */ typedef struct { U8 state; /*< 0: 1> State of the SMS Entity */ U8 v_cmms_mode; /*< 1: 1> valid-flag */ U8 cmms_mode; /*< 2: 1> Specifies the mode for +CMMS */ U8 _align0; /*< 3: 1> alignment */ } T_MNSMS_REPORT_IND; #endif #ifndef __T_MNSMS_STATUS_IND__ #define __T_MNSMS_STATUS_IND__ /* * * CCDGEN:WriteStruct_Count==1983 */ typedef struct { T_sms_sdu sms_sdu; /*< 0:180> SIM-PDU */ } T_MNSMS_STATUS_IND; #endif #ifndef __T_MNSMS_DELETE_REQ__ #define __T_MNSMS_DELETE_REQ__ /* * * CCDGEN:WriteStruct_Count==1984 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 delete_status; /*< 2: 1> Delete flag */ U8 _align0; /*< 3: 1> alignment */ } T_MNSMS_DELETE_REQ; #endif #ifndef __T_MNSMS_DELETE_CNF__ #define __T_MNSMS_DELETE_CNF__ /* * * CCDGEN:WriteStruct_Count==1985 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U16 cause; /*< 2: 2> error code */ U8 delete_rec_next; /*< 4: 1> Next Record to be deleted. */ U8 _align0; /*< 5: 1> alignment */ U8 _align1; /*< 6: 1> alignment */ U8 _align2; /*< 7: 1> alignment */ } T_MNSMS_DELETE_CNF; #endif #ifndef __T_MNSMS_READ_REQ__ #define __T_MNSMS_READ_REQ__ /* * * CCDGEN:WriteStruct_Count==1986 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 read_mode; /*< 2: 1> Read Mode */ U8 status; /*< 3: 1> message status */ } T_MNSMS_READ_REQ; #endif #ifndef __T_MNSMS_READ_CNF__ #define __T_MNSMS_READ_CNF__ /* * * CCDGEN:WriteStruct_Count==1987 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 rec_next; /*< 2: 1> number of a following record with a valid message, if existent */ U8 rec_max; /*< 3: 1> maximum number of records (1..255) in EF(SMS) or other memory */ U16 cause; /*< 4: 2> error code */ U8 rec_status; /*< 6: 1> number of a record in EF(SMSR) related to the given stored message */ U8 status; /*< 7: 1> message status */ T_sms_sdu sms_sdu; /*< 8:180> SIM-PDU */ } T_MNSMS_READ_CNF; #endif #ifndef __T_MNSMS_STORE_REQ__ #define __T_MNSMS_STORE_REQ__ /* * * CCDGEN:WriteStruct_Count==1988 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 condx; /*< 2: 1> write condition */ U8 status; /*< 3: 1> message status */ T_sms_sdu sms_sdu; /*< 4:180> SIM-PDU */ } T_MNSMS_STORE_REQ; #endif #ifndef __T_MNSMS_STORE_CNF__ #define __T_MNSMS_STORE_CNF__ /* * * CCDGEN:WriteStruct_Count==1989 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U16 cause; /*< 2: 2> error code */ } T_MNSMS_STORE_CNF; #endif #ifndef __T_MNSMS_SUBMIT_REQ__ #define __T_MNSMS_SUBMIT_REQ__ /* * * CCDGEN:WriteStruct_Count==1990 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U8 condx; /*< 2: 1> write condition */ U8 modify; /*< 3: 1> Modifier */ // ELEM-FF: REL99 // U8 auto_rep_flag; /*< 0: 0> Added auto_rep_flag variable */ T_sms_sdu sms_sdu; /*< 4:180> SIM-PDU */ } T_MNSMS_SUBMIT_REQ; #endif #ifndef __T_MNSMS_SUBMIT_CNF__ #define __T_MNSMS_SUBMIT_CNF__ /* * * CCDGEN:WriteStruct_Count==1991 */ typedef struct { U8 mem_type; /*< 0: 1> memory type */ U8 rec_num; /*< 1: 1> record number */ U16 cause; /*< 2: 2> error code */ U8 tp_mr; /*< 4: 1> TP message reference */ U8 _align0; /*< 5: 1> alignment */ U8 _align1; /*< 6: 1> alignment */ U8 _align2; /*< 7: 1> alignment */ T_sms_sdu sms_sdu; /*< 8:180> SIM-PDU */ } T_MNSMS_SUBMIT_CNF; #endif #ifndef __T_MNSMS_COMMAND_REQ__ #define __T_MNSMS_COMMAND_REQ__ /* * * CCDGEN:WriteStruct_Count==1992 */ typedef struct { // ELEM-FF: REL99 // U8 auto_rep_flag; /*< 0: 0> Added auto_rep_flag variable */ T_sms_sdu sms_sdu; /*< 0:180> SIM-PDU */ } T_MNSMS_COMMAND_REQ; #endif #ifndef __T_MNSMS_COMMAND_CNF__ #define __T_MNSMS_COMMAND_CNF__ /* * * CCDGEN:WriteStruct_Count==1993 */ typedef struct { U16 cause; /*< 0: 2> error code */ U8 tp_mr; /*< 2: 1> TP message reference */ U8 _align0; /*< 3: 1> alignment */ T_sms_sdu sms_sdu; /*< 4:180> SIM-PDU */ } T_MNSMS_COMMAND_CNF; #endif #ifndef __T_MNSMS_ACK_RES__ #define __T_MNSMS_ACK_RES__ /* * * CCDGEN:WriteStruct_Count==1994 */ typedef struct { U8 resp; /*< 0: 1> type of response */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_sms_sdu sms_sdu; /*< 4:180> SIM-PDU */ } T_MNSMS_ACK_RES; #endif #ifndef __T_MNSMS_CONFIGURE_REQ__ #define __T_MNSMS_CONFIGURE_REQ__ /* * * CCDGEN:WriteStruct_Count==1995 */ typedef struct { U8 pref_mem_3; /*< 0: 1> memory type */ U8 mt; /*< 1: 1> mobile terminated message handling */ U8 ds; /*< 2: 1> status report message handling */ U8 mhc; /*< 3: 1> status report message handling */ U8 v_cmms_mode; /*< 4: 1> valid-flag */ U8 cmms_mode; /*< 5: 1> Specifies the mode for +CMMS */ U8 _align0; /*< 6: 1> alignment */ U8 v_tmms_val; /*< 7: 1> valid-flag */ U16 tmms_val; /*< 8: 2> Timer value for +CMMS command */ U8 _align1; /*< 10: 1> alignment */ U8 _align2; /*< 11: 1> alignment */ } T_MNSMS_CONFIGURE_REQ; #endif #ifndef __T_MNSMS_ERROR_IND__ #define __T_MNSMS_ERROR_IND__ /* * * CCDGEN:WriteStruct_Count==1996 */ typedef struct { U16 cause; /*< 0: 2> error code */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_MNSMS_ERROR_IND; #endif #ifndef __T_MNSMS_MO_SERV_REQ__ #define __T_MNSMS_MO_SERV_REQ__ /* * * CCDGEN:WriteStruct_Count==1997 */ typedef struct { U8 mo_sms_serv; /*< 0: 1> MO SMS Service */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_MNSMS_MO_SERV_REQ; #endif #ifndef __T_MNSMS_MO_SERV_CNF__ #define __T_MNSMS_MO_SERV_CNF__ /* * * CCDGEN:WriteStruct_Count==1998 */ typedef struct { U8 mo_sms_serv; /*< 0: 1> MO SMS Service */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_MNSMS_MO_SERV_CNF; #endif #ifndef __T_MNSMS_PAUSE_REQ__ #define __T_MNSMS_PAUSE_REQ__ /* * * CCDGEN:WriteStruct_Count==1999 */ typedef struct { U8 dummy; /*< 0: 1> no parameters */ } T_MNSMS_PAUSE_REQ; #endif #ifndef __T_MNSMS_RESUME_REQ__ #define __T_MNSMS_RESUME_REQ__ /* * * CCDGEN:WriteStruct_Count==2000 */ typedef struct { U8 dummy; /*< 0: 1> no parameters */ } T_MNSMS_RESUME_REQ; #endif #ifndef __T_MNSMS_RESUME_CNF__ #define __T_MNSMS_RESUME_CNF__ /* * * CCDGEN:WriteStruct_Count==2001 */ typedef struct { U16 cause; /*< 0: 2> error code */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_MNSMS_RESUME_CNF; #endif #ifndef __T_MNSMS_QUERY_REQ__ #define __T_MNSMS_QUERY_REQ__ /* * * CCDGEN:WriteStruct_Count==2002 */ typedef struct { U8 query_type; /*< 0: 1> specifies to which status the query request refers to */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_MNSMS_QUERY_REQ; #endif #ifndef __T_MNSMS_QUERY_CNF__ #define __T_MNSMS_QUERY_CNF__ /* * * CCDGEN:WriteStruct_Count==2003 */ typedef struct { U8 query_type; /*< 0: 1> specifies to which status the query request refers to */ U8 v_deliver_status; /*< 1: 1> valid-flag */ U8 deliver_status; /*< 2: 1> sms delivery status - pause or resume */ U8 _align0; /*< 3: 1> alignment */ } T_MNSMS_QUERY_CNF; #endif #ifndef __T_MNSMS_OTA_MESSAGE_IND__ #define __T_MNSMS_OTA_MESSAGE_IND__ /* * * CCDGEN:WriteStruct_Count==2004 */ typedef struct { U8 tp_pid; /*< 0: 1> TP Protocol Identifier */ U8 tp_dcs; /*< 1: 1> TP Data Coding Scheme */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ T_tp_ud tp_ud; /*< 4:164> TP User Data (type defined in "m_sms.h") */ } T_MNSMS_OTA_MESSAGE_IND; #endif #ifndef __T_MNSMS_OTA_MESSAGE_RES__ #define __T_MNSMS_OTA_MESSAGE_RES__ /* * * CCDGEN:WriteStruct_Count==2005 */ typedef struct { U8 tp_pid; /*< 0: 1> TP Protocol Identifier */ U8 tp_dcs; /*< 1: 1> TP Data Coding Scheme */ U8 len; /*< 2: 1> length of the OTA response */ U8 packedlen; /*< 3: 1> length of the OTA response */ U8 data[20]; /*< 4: 20> IMEI and category status of the mobile to be extracted from TP user data */ } T_MNSMS_OTA_MESSAGE_RES; #endif // PRIM-FF: REL99 // #ifndef __T_MNSMS_RETRANS_REQ__ // #define __T_MNSMS_RETRANS_REQ__ // // // CCDGEN:WriteStruct_Count==2006 // // typedef struct // { // ELEM-FF: REL99 // U8 auto_rep_flag; /*< 0: 0> Added auto_rep_flag variable */ // } T_MNSMS_RETRANS_REQ; // #endif // // PRIM-FF: REL99 // #ifndef __T_MNSMS_RETRANS_CNF__ // #define __T_MNSMS_RETRANS_CNF__ // // // CCDGEN:WriteStruct_Count==2007 // // typedef struct // { // U16 cause; /*< 0: 2> error code */ // U8 mem_type; /*< 2: 1> memory type */ // U8 rec_num; /*< 3: 1> record number */ // U8 tp_mr; /*< 4: 1> TP message reference */ // U8 _align0; /*< 5: 1> alignment */ // U8 _align1; /*< 6: 1> alignment */ // U8 _align2; /*< 7: 1> alignment */ // T_sms_sdu sms_sdu; /*< 8:180> SIM-PDU */ // } T_MNSMS_RETRANS_CNF; // #endif // // PRIM-FF: REL99 // #ifndef __T_MNSMS_SEND_PROG_IND__ // #define __T_MNSMS_SEND_PROG_IND__ // // // CCDGEN:WriteStruct_Count==2008 // // typedef struct // { // ELEM-FF: REL99 // U8 resend_count; /*< 0: 0> To resend the count to MMI during retransmission */ // ELEM-FF: REL99 // U8 max_retrans; /*< 0: 0> Maximum number of retransmission allowed which is communicated to MMI */ // } T_MNSMS_SEND_PROG_IND; // #endif // #include "CDG_LEAVE.h" #endif