FreeCalypso > hg > fc-magnetite
view cdg3/cdginc-locosto/m_mm.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 : m_mm.h | | SOURCE : "msg\mm.mdf" | | LastModified : "2006-03-22" | | IdAndVersion : "6147.602.06.106" | | SrcFileTime : "Wed Nov 28 10:19:30 2007" | | Generated by CCDGEN_2.5.5A on Thu Sep 25 09:18:52 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 M_MM_H #define M_MM_H #define CDG_ENTER__M_MM_H #define CDG_ENTER__FILENAME _M_MM_H #define CDG_ENTER__M_MM_H__FILE_TYPE CDGINC #define CDG_ENTER__M_MM_H__LAST_MODIFIED _2006_03_22 #define CDG_ENTER__M_MM_H__ID_AND_VERSION _6147_602_06_106 #define CDG_ENTER__M_MM_H__SRC_FILE_TIME _Wed_Nov_28_10_19_30_2007 #include "CDG_ENTER.h" #undef CDG_ENTER__M_MM_H #undef CDG_ENTER__FILENAME #include "m_mm.val" #include "m_rr_com.h" /* * bitbuffer structure for the element auth_sres */ #ifndef __T_BUF_auth_sres__ #define __T_BUF_auth_sres__ typedef struct { U16 l_auth_sres; U16 o_auth_sres; U8 b_auth_sres[8]; } BUF_auth_sres; /* size <12> */ #endif /* * bitbuffer structure for the element tmsi */ #ifndef __T_BUF_tmsi__ #define __T_BUF_tmsi__ typedef struct { U16 l_tmsi; U16 o_tmsi; U8 b_tmsi[8]; } BUF_tmsi; /* size <12> */ #endif #ifndef __T_auth_rand__ #define __T_auth_rand__ /* * Authentication parameter RAND * CCDGEN:WriteStruct_Count==295 */ typedef struct { U8 c_rand; /*< 0: 1> counter */ U8 rand[16]; /*< 1: 16> RAND value */ U8 _align0; /*< 17: 1> alignment */ U8 _align1; /*< 18: 1> alignment */ U8 _align2; /*< 19: 1> alignment */ } T_auth_rand; #endif #ifndef __T_ciph_key_num__ #define __T_ciph_key_num__ /* * Ciphering Key Sequence Number * CCDGEN:WriteStruct_Count==296 */ typedef struct { U8 key_seq; /*< 0: 1> key sequence */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_ciph_key_num; #endif #ifndef __T_follow_proceed__ #define __T_follow_proceed__ /* * Follow on proceed * CCDGEN:WriteStruct_Count==297 */ /* typedef void T_follow_proceed;*/ #endif #ifndef __T_ident__ #define __T_ident__ /* * Identity type * CCDGEN:WriteStruct_Count==298 */ typedef struct { U8 ident_type; /*< 0: 1> Type of identity */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_ident; #endif #ifndef __T_loc_area_ident__ #define __T_loc_area_ident__ /* * Location Area Identification * CCDGEN:WriteStruct_Count==299 */ typedef struct { U8 mcc[3]; /*< 0: 3> Mobile Country Code */ U8 c_mnc; /*< 3: 1> counter */ U8 mnc[3]; /*< 4: 3> Mobile Network Code */ U8 _align0; /*< 7: 1> alignment */ U16 lac; /*< 8: 2> Location Area Code */ U8 _align1; /*< 10: 1> alignment */ U8 _align2; /*< 11: 1> alignment */ } T_loc_area_ident; #endif #ifndef __T_loc_upd_type__ #define __T_loc_upd_type__ /* * Location updating type * CCDGEN:WriteStruct_Count==300 */ typedef struct { U8 follow; /*< 0: 1> Follow on request */ U8 lut; /*< 1: 1> Location updating type */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_loc_upd_type; #endif #ifndef __T_mob_id__ #define __T_mob_id__ /* * Mobile Identity * CCDGEN:WriteStruct_Count==301 */ typedef struct { U8 ident_type; /*< 0: 1> Type of identity */ U8 odd_even; /*< 1: 1> Odd Even indicaction */ U8 v_ident_dig; /*< 2: 1> valid-flag */ U8 c_ident_dig; /*< 3: 1> counter */ U8 ident_dig[16]; /*< 4: 16> Identity digit */ U8 _align0; /*< 20: 1> alignment */ U8 _align1; /*< 21: 1> alignment */ U8 _align2; /*< 22: 1> alignment */ U8 v_tmsi; /*< 23: 1> valid-flag */ BUF_tmsi tmsi; /*< 24: 12> TMSI */ U8 v_dmy; /*< 36: 1> valid-flag */ U8 c_dmy; /*< 37: 1> counter */ U8 dmy[16]; /*< 38: 16> Dummy */ U8 _align3; /*< 54: 1> alignment */ U8 _align4; /*< 55: 1> alignment */ } T_mob_id; #endif #ifndef __T_pd_and_sapi__ #define __T_pd_and_sapi__ /* * PD and SAPI * CCDGEN:WriteStruct_Count==302 */ typedef struct { U8 sapi; /*< 0: 1> SAPI */ U8 pd; /*< 1: 1> PD */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_pd_and_sapi; #endif #ifndef __T_full_net_name__ #define __T_full_net_name__ /* * Full Network Name * CCDGEN:WriteStruct_Count==303 */ typedef struct { U8 cs; /*< 0: 1> Coding Scheme */ U8 add_ci; /*< 1: 1> Add Country Information */ U8 num_spare; /*< 2: 1> Number of spare bits */ U8 c_text; /*< 3: 1> counter */ U8 text[MAXNAME]; /*< 4: 40> text string */ } T_full_net_name; #endif /* * Short Network Name * CCDGEN:WriteStruct_Count==304 */ #ifndef __T_short_net_name__ #define __T_short_net_name__ typedef T_full_net_name T_short_net_name; #endif #ifndef __T_net_tz__ #define __T_net_tz__ /* * Network Time Zone * CCDGEN:WriteStruct_Count==305 */ typedef struct { U8 tz; /*< 0: 1> time zone */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_net_tz; #endif #ifndef __T_net_tz_and_time__ #define __T_net_tz_and_time__ /* * Network Time Zone and Time * CCDGEN:WriteStruct_Count==306 */ typedef struct { U8 year[2]; /*< 0: 2> year */ U8 month[2]; /*< 2: 2> month */ U8 day[2]; /*< 4: 2> day */ U8 hour[2]; /*< 6: 2> hour */ U8 minute[2]; /*< 8: 2> minute */ U8 second[2]; /*< 10: 2> second */ U8 tz; /*< 12: 1> time zone */ U8 _align0; /*< 13: 1> alignment */ U8 _align1; /*< 14: 1> alignment */ U8 _align2; /*< 15: 1> alignment */ } T_net_tz_and_time; #endif // STRUCT-FF: REL99 #ifndef __T_lsa_identifier__ #define __T_lsa_identifier__ /* * LSA identifier * CCDGEN:WriteStruct_Count==307 */ typedef struct { U8 c_lsa_id; /*< 0: 1> counter */ U8 lsa_id[3]; /*< 1: 3> LSA identifier */ } T_lsa_identifier; #endif // STRUCT-FF: REL99 #ifndef __T_daylight_save_time__ #define __T_daylight_save_time__ /* * Daylight Saving Time * CCDGEN:WriteStruct_Count==308 */ typedef struct { U8 save_time_value; /*< 0: 1> Daylight Saving Time Value */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_daylight_save_time; #endif #ifndef __T_eqv_plmn__ #define __T_eqv_plmn__ /* * PLMN * CCDGEN:WriteStruct_Count==309 */ typedef struct { U8 mcc[3]; /*< 0: 3> Mobile Country Code */ U8 c_mnc; /*< 3: 1> counter */ U8 mnc[3]; /*< 4: 3> Mobile Network Code */ U8 _align0; /*< 7: 1> alignment */ } T_eqv_plmn; #endif #ifndef __T_eqv_plmn_list__ #define __T_eqv_plmn_list__ /* * Equivalent PLMN list * CCDGEN:WriteStruct_Count==310 */ typedef struct { U8 _align0; /*< 0: 1> alignment */ U8 _align1; /*< 1: 1> alignment */ U8 _align2; /*< 2: 1> alignment */ U8 c_eqv_plmn; /*< 3: 1> counter */ T_eqv_plmn eqv_plmn[5]; /*< 4: 40> PLMN */ } T_eqv_plmn_list; #endif #ifndef __T_cts_per__ #define __T_cts_per__ /* * Structured Element * CCDGEN:WriteStruct_Count==311 */ /* typedef void T_cts_per;*/ #endif /* * End of substructure section, begin of message definition section */ #ifndef __T_D_ABORT__ #define __T_D_ABORT__ /* * * CCDGEN:WriteStruct_Count==312 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 rej_cause; /*< 1: 1> Reject cause */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_D_ABORT; #endif #ifndef __T_D_AUTH_REJ__ #define __T_D_AUTH_REJ__ /* * * CCDGEN:WriteStruct_Count==313 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_D_AUTH_REJ; #endif #ifndef __T_D_AUTH_REQ__ #define __T_D_AUTH_REQ__ /* * * CCDGEN:WriteStruct_Count==314 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_ciph_key_num ciph_key_num; /*< 4: 4> Ciphering Key Sequence Number */ T_auth_rand auth_rand; /*< 8: 20> Authentication parameter RAND */ } T_D_AUTH_REQ; #endif #ifndef __T_U_AUTH_RES__ #define __T_U_AUTH_RES__ /* * * CCDGEN:WriteStruct_Count==315 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ BUF_auth_sres auth_sres; /*< 4: 12> Authentication parameter SRES */ } T_U_AUTH_RES; #endif #ifndef __T_U_CM_REESTAB_REQ__ #define __T_U_CM_REESTAB_REQ__ /* * * CCDGEN:WriteStruct_Count==316 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_ciph_key_num ciph_key_num; /*< 4: 4> Ciphering Key Sequence Number */ T_mob_class_2 mob_class_2; /*< 8: 20> Mobile Station Classmark 2 (type defined in "m_rr_com.h") */ T_mob_id mob_id; /*< 28: 56> Mobile Identity */ U8 _align3; /*< 84: 1> alignment */ U8 _align4; /*< 85: 1> alignment */ U8 _align5; /*< 86: 1> alignment */ U8 v_loc_area_ident; /*< 87: 1> valid-flag */ T_loc_area_ident loc_area_ident; /*< 88: 12> Location Area Identification */ } T_U_CM_REESTAB_REQ; #endif #ifndef __T_U_CM_SERV_ABORT__ #define __T_U_CM_SERV_ABORT__ /* * * CCDGEN:WriteStruct_Count==317 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_U_CM_SERV_ABORT; #endif #ifndef __T_D_CM_SERV_ACCEPT__ #define __T_D_CM_SERV_ACCEPT__ /* * * CCDGEN:WriteStruct_Count==318 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_D_CM_SERV_ACCEPT; #endif #ifndef __T_D_CM_SERV_REJ__ #define __T_D_CM_SERV_REJ__ /* * * CCDGEN:WriteStruct_Count==319 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 rej_cause; /*< 1: 1> Reject cause */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_D_CM_SERV_REJ; #endif #ifndef __T_U_CM_SERV_REQ__ #define __T_U_CM_SERV_REQ__ /* * * CCDGEN:WriteStruct_Count==320 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 cm_serv_type; /*< 1: 1> CM service type */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ T_ciph_key_num ciph_key_num; /*< 4: 4> Ciphering Key Sequence Number */ T_mob_class_2 mob_class_2; /*< 8: 20> Mobile Station Classmark 2 (type defined in "m_rr_com.h") */ T_mob_id mob_id; /*< 28: 56> Mobile Identity */ } T_U_CM_SERV_REQ; #endif #ifndef __T_D_IDENT_REQ__ #define __T_D_IDENT_REQ__ /* * * CCDGEN:WriteStruct_Count==321 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_ident ident; /*< 4: 4> Identity type */ } T_D_IDENT_REQ; #endif #ifndef __T_U_IDENT_RES__ #define __T_U_IDENT_RES__ /* * * CCDGEN:WriteStruct_Count==322 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_mob_id mob_id; /*< 4: 56> Mobile Identity */ } T_U_IDENT_RES; #endif #ifndef __T_U_IMSI_DETACH_IND__ #define __T_U_IMSI_DETACH_IND__ /* * * CCDGEN:WriteStruct_Count==323 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_mob_class_1 mob_class_1; /*< 4: 4> Mobile Station Classmark 1 (type defined in "m_rr_com.h") */ T_mob_id mob_id; /*< 8: 56> Mobile Identity */ } T_U_IMSI_DETACH_IND; #endif #ifndef __T_D_LOC_UPD_ACCEPT__ #define __T_D_LOC_UPD_ACCEPT__ /* * * CCDGEN:WriteStruct_Count==324 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_loc_area_ident loc_area_ident; /*< 4: 12> Location Area Identification */ U8 _align3; /*< 16: 1> alignment */ U8 _align4; /*< 17: 1> alignment */ U8 _align5; /*< 18: 1> alignment */ U8 v_mob_id; /*< 19: 1> valid-flag */ T_mob_id mob_id; /*< 20: 56> Mobile Identity */ U8 _align6; /*< 76: 1> alignment */ U8 _align7; /*< 77: 1> alignment */ U8 _align8; /*< 78: 1> alignment */ U8 v_follow_proceed; /*< 79: 1> valid-flag */ U8 _align9; /*< 80: 1> alignment */ U8 _align10; /*< 81: 1> alignment */ U8 _align11; /*< 82: 1> alignment */ U8 v_cts_per; /*< 83: 1> valid-flag */ U8 _align12; /*< 84: 1> alignment */ U8 _align13; /*< 85: 1> alignment */ U8 _align14; /*< 86: 1> alignment */ U8 v_eqv_plmn_list; /*< 87: 1> valid-flag */ T_eqv_plmn_list eqv_plmn_list; /*< 88: 44> Equivalent PLMN list */ } T_D_LOC_UPD_ACCEPT; #endif #ifndef __T_D_LOC_UPD_REJ__ #define __T_D_LOC_UPD_REJ__ /* * * CCDGEN:WriteStruct_Count==325 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 rej_cause; /*< 1: 1> Reject cause */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_D_LOC_UPD_REJ; #endif #ifndef __T_U_LOC_UPD_REQ__ #define __T_U_LOC_UPD_REQ__ /* * * CCDGEN:WriteStruct_Count==326 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_loc_upd_type loc_upd_type; /*< 4: 4> Location updating type */ T_ciph_key_num ciph_key_num; /*< 8: 4> Ciphering Key Sequence Number */ T_loc_area_ident loc_area_ident; /*< 12: 12> Location Area Identification */ T_mob_class_1 mob_class_1; /*< 24: 4> Mobile Station Classmark 1 (type defined in "m_rr_com.h") */ T_mob_id mob_id; /*< 28: 56> Mobile Identity */ } T_U_LOC_UPD_REQ; #endif #ifndef __T_B_MM_STATUS__ #define __T_B_MM_STATUS__ /* * * CCDGEN:WriteStruct_Count==327 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 rej_cause; /*< 1: 1> Reject cause */ U8 _align0; /*< 2: 1> alignment */ U8 _align1; /*< 3: 1> alignment */ } T_B_MM_STATUS; #endif #ifndef __T_D_TMSI_REALLOC_CMD__ #define __T_D_TMSI_REALLOC_CMD__ /* * * CCDGEN:WriteStruct_Count==328 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_loc_area_ident loc_area_ident; /*< 4: 12> Location Area Identification */ T_mob_id mob_id; /*< 16: 56> Mobile Identity */ } T_D_TMSI_REALLOC_CMD; #endif #ifndef __T_U_TMSI_REALLOC_COMP__ #define __T_U_TMSI_REALLOC_COMP__ /* * * CCDGEN:WriteStruct_Count==329 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ } T_U_TMSI_REALLOC_COMP; #endif #ifndef __T_D_CM_SERVICE_PROMPT__ #define __T_D_CM_SERVICE_PROMPT__ /* * * CCDGEN:WriteStruct_Count==330 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 _align2; /*< 3: 1> alignment */ T_pd_and_sapi pd_and_sapi; /*< 4: 4> PD and SAPI */ } T_D_CM_SERVICE_PROMPT; #endif #ifndef __T_D_MM_INFORMATION__ #define __T_D_MM_INFORMATION__ /* * * CCDGEN:WriteStruct_Count==331 */ typedef struct { U8 msg_type; /*< 0: 1> Message Type */ U8 _align0; /*< 1: 1> alignment */ U8 _align1; /*< 2: 1> alignment */ U8 v_full_net_name; /*< 3: 1> valid-flag */ T_full_net_name full_net_name; /*< 4: 44> Full Network Name */ U8 _align2; /*< 48: 1> alignment */ U8 _align3; /*< 49: 1> alignment */ U8 _align4; /*< 50: 1> alignment */ U8 v_short_net_name; /*< 51: 1> valid-flag */ T_short_net_name short_net_name; /*< 52: 44> Short Network Name */ U8 _align5; /*< 96: 1> alignment */ U8 _align6; /*< 97: 1> alignment */ U8 _align7; /*< 98: 1> alignment */ U8 v_net_tz; /*< 99: 1> valid-flag */ T_net_tz net_tz; /*<100: 4> Network Time Zone */ U8 _align8; /*<104: 1> alignment */ U8 _align9; /*<105: 1> alignment */ U8 _align10; /*<106: 1> alignment */ U8 v_net_tz_and_time; /*<107: 1> valid-flag */ T_net_tz_and_time net_tz_and_time; /*<108: 16> Network Time Zone and Time */ U8 _align11; /*<124: 1> alignment */ U8 _align12; /*<125: 1> alignment */ U8 _align13; /*<126: 1> alignment */ U8 v_lsa_identifier; /*<127: 1> valid-flag */ T_lsa_identifier lsa_identifier; /*<128: 4> LSA identifier */ U8 _align14; /*<132: 1> alignment */ U8 _align15; /*<133: 1> alignment */ U8 _align16; /*<134: 1> alignment */ U8 v_daylight_save_time; /*<135: 1> valid-flag */ T_daylight_save_time daylight_save_time; /*<136: 4> Daylight Saving Time */ } T_D_MM_INFORMATION; #endif #include "CDG_LEAVE.h" #endif