FreeCalypso > hg > fc-magnetite
view cdg3/cdginc-conservative/p_mnsms.val @ 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.val | | 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_VAL #define P_MNSMS_VAL #define CDG_ENTER__P_MNSMS_VAL #define CDG_ENTER__FILENAME _P_MNSMS_VAL #define CDG_ENTER__P_MNSMS_VAL__FILE_TYPE CDGINC #define CDG_ENTER__P_MNSMS_VAL__LAST_MODIFIED _2002_04_19 #define CDG_ENTER__P_MNSMS_VAL__ID_AND_VERSION _6147_103_96_107 #define CDG_ENTER__P_MNSMS_VAL__SRC_FILE_TIME _Thu_Nov_29_09_48_28_2007 #include "CDG_ENTER.h" #undef CDG_ENTER__P_MNSMS_VAL #undef CDG_ENTER__FILENAME #include "m_sms.val" /* Access values independent from the corresponding h-file. */ /* * Value constants for VAL_mem_type */ #define MEM_ME (0x1) /* mobile equipment memory 1 */ #define MEM_SM (0x3) /* subscriber identity module memory */ #define MEM_SR (0x5) /* status report memory */ /* * Value constants for VAL_cause */ #define SMS_NO_ERROR (0x89ff) /* No error */ #define SMS_CAUSE_PARAM_WRONG (0xc900) /* Wrong parameter in primitive */ #define SMS_CAUSE_ENTITY_BUSY (0xc901) /* Entity is busy */ #define SMS_CAUSE_OPER_NOT_ALLW (0xc902) /* Operation not allowed */ #define SMS_CAUSE_OPER_NOT_SUPP (0xc903) /* Operation not supported */ #define SMS_CAUSE_SIM_BUSY (0xc904) /* SIM busy */ #define SMS_CAUSE_MEM_FAIL (0xc905) /* Memory failure */ #define SMS_CAUSE_INV_INDEX (0xc906) /* Invalid memory index */ #define SMS_CAUSE_MEM_FULL (0xc908) /* Memory full */ #define SMS_CAUSE_NO_SERVICE (0xc909) /* No network service */ #define SMS_CAUSE_NET_TIMEOUT (0xc90a) /* Network timeout */ #define SMS_CAUSE_UNEXP_CNMA (0xc90b) /* No +CNMA acknowledgement expected */ #define SMS_CAUSE_OTHER_ERROR (0xc90f) /* Any other error */ #define SMS_CAUSE_MEM_AVAIL (0xc90c) /* Memory available after full */ // VAL-FF: REL99 // #define SMS_CAUSE_FAILED_MSG_NOT_FOUND (0xc90e)/* Failed Message not found during Transmission */ /* * Value constants for VAL_state */ #define SMS_STATE_READY (0x0) /* SMS is full operable */ #define SMS_STATE_INITIALISING (0x1) /* SMS is in initialisation state */ #define SMS_STATE_BUSY (0x2) /* SMS is in a busy condition */ #define SMS_STATE_NOT_AVAILABLE (0xff) /* SMS is inoperable */ /* * Value constants for VAL_condx */ #define SMS_CONDX_OVR_NON (0x0) /* do not overwrite an existing message */ #define SMS_CONDX_OVR_MO (0x1) /* overwrite only an exisiting mobile originated message */ #define SMS_CONDX_OVR_ANY (0x2) /* overwrite any existing message */ /* * Value constants for VAL_modify */ #define SMS_MODIFY_NON (0x0) /* no modification */ #define SMS_MODIFY_TPOA (0x1) /* substitution of TP-OA */ #define SMS_MODIFY_SCA (0x2) /* substitution of SCA */ #define SMS_MODIFY_TPOA_SCA (0x3) /* substitution of TP-OA and SCA */ #define SMS_MODIFY_ALL (0x4) /* substitution of the complete message */ /* * Value constants for VAL_rec_num */ #define SMS_RECORD_NOT_EXIST (0x0) /* record is not existing */ /* * Value constants for VAL_status */ #define SMS_RECORD_FREE (0x0) /* Free record */ #define SMS_RECORD_REC_UNREAD (0x3) /* MT record, not read */ #define SMS_RECORD_REC_READ (0x1) /* MT record, already read */ #define SMS_RECORD_STO_UNSENT (0x7) /* MO record, not sent */ #define SMS_RECORD_STO_SENT (0x5) /* MO record, already sent, status report not requested */ #define SMS_RECORD_STAT_UNRCVD (0xd) /* MO record, already sent, status report requested, not received */ #define SMS_RECORD_STAT_UNSTRD (0x15) /* MO record, already sent, status report received, not stored */ #define SMS_RECORD_STAT_STRD (0x1d) /* MO record, already sent, status report received and stored */ #define SMS_RECORD_INVALID (0xe0) /* The record keeps unrecognizable data */ /* * Value constants for VAL_mt */ #define MT0 (0x0) /* Mobile Terminated Mode 0 */ #define MT1 (0x1) /* Mobile Terminated Mode 1 */ #define MT2 (0x2) /* Mobile Terminated Mode 2 */ #define MT3 (0x3) /* Mobile Terminated Mode 3 */ #define MT_DEF (0x4) /* Mobile Terminated Mode Default */ /* * Value constants for VAL_ds */ #define DS0 (0x0) /* Status Report Mode 0: no status report to be returned */ #define DS1 (0x1) /* Status Report Mode 1: status report returned to MMI */ #define DS2 (0x2) /* Status Report Mode 2: status report stored, if possible */ /* * Value constants for VAL_mhc */ #define SMS_MHC_DEF (0x0) /* default (Phase 2) */ #define SMS_MHC_PH2 (0x2) /* Phase 2 */ #define SMS_MHC_PH2PLUS (0x3) /* Phase 2+ */ /* * Value constants for VAL_read_mode */ #define READ_NORMAL (0x0) /* Normal reading */ #define READ_PREVIEW (0x1) /* Reading without preview */ #define READ_STATUS_CHANGE (0x2) /* Change only status */ /* * Value constants for VAL_resp */ #define SMS_RP_ACK (0x0) /* send RP-ACK to network */ #define SMS_RP_ERROR (0x1) /* send RP-ERROR to network */ /* * Value constants for VAL_mo_sms_serv */ #define GPRS_SMS_GPRS_ONLY (0x0) /* Use GPRS only for MO SMS */ #define GPRS_SMS_CCT_ONLY (0x1) /* Use CCT only for MO SMS */ #define GPRS_SMS_GPRS_PREF (0x2) /* Use GPRS in preference for MO SMS */ #define GPRS_SMS_CCT_PREF (0x3) /* Use CCT in preference for MO SMS */ /* * Value constants for VAL_query */ #define SMS_QUERY_DELIVER_STATUS (0x1) /* Query Request is for delivery status (pause or resume) */ /* * Value constants for VAL_deliver_status */ #define SMS_DELIVER_STATUS_PAUSE (0x10) /* SMS delivery paused by user */ #define SMS_DELIVER_STATUS_RESUME (0x11) /* SMS delivery to user allowed */ /* * Value constants for VAL_cmms_mode */ #define CMMS_MODE_DEF (0x0) /* Default value of 0 for +CMMS mode. The mode switches to 0 when timer expires if the mode set was 1. */ #define CMMS_MODE_ONE (0x1) /* Mode value of one for +CMMS mode. For this mode set, when the timer expires, mode is switched back to 0. */ #define CMMS_MODE_TWO (0x2) /* Mode value of two for +CMMS mode. For this mode set, even after the timer expiry mode is not switched to 0 */ /* * Value constants for VAL_delete_status */ #define CMGD_DEL_INDEX (0x0) /* Delete the messages specified by the index. */ #define CMGD_DEL_READ (0x1) /* Ignore the index and delete all the read messages. */ #define CMGD_DEL_READ_SENT (0x2) /* Ignore the index and delete all the read and sent messages. */ #define CMGD_DEL_READ_SENT_UNSENT (0x3) /* Ignore the index and delete all the read, send and unsent messages. */ #define CMGD_DEL_ALL (0x4) /* Ignore the index and delete all the messages whatever the status it is. */ // VALTAB-FF: REL99 // // Value constants for VAL_auto_rep_flag // // VAL-FF: REL99 // #define AUTO_REP_FLAG_DISABLED (0x0) /* Do not attempt retransmission */ // VAL-FF: REL99 // #define AUTO_REP_FLAG_ENABLED (0x1) /* Attempt retransmission */ /* * user defined constants */ #define SMS_MSG_LEN (0x8c) #define SMS_CMD_LEN (0x9d) #define SIM_PDU_LEN (0xaf) #define SMSCP_ORIGINATING_ENTITY (0x7) #define SMSRP_ORIGINATING_ENTITY (0x8) #define SMSTP_ORIGINATING_ENTITY (0x9) #include "CDG_LEAVE.h" #endif