diff options
author | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-01-17 08:35:53 +0000 |
---|---|---|
committer | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-01-17 08:35:53 +0000 |
commit | 9b7916395e21e4efe3d0fc76adad30c3b1f169be (patch) | |
tree | 3a028dee93465cd2a5461055a8300d9db7b56855 /src/gsmd | |
parent | 6274c0663e6b7b634187ace52d2a3b1f4b29584a (diff) |
gsmd: fix CMT_parse comma error (Sean Chiang)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3861 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd')
-rw-r--r-- | src/gsmd/sms_cb.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/gsmd/sms_cb.c b/src/gsmd/sms_cb.c index 0e97749..7d69f12 100644 --- a/src/gsmd/sms_cb.c +++ b/src/gsmd/sms_cb.c @@ -39,6 +39,7 @@ #include <gsmd/unsolicited.h> #include <gsmd/sms.h> #include <gsmd/talloc.h> +#include <gsmd/extrsp.h> static const char *ts0705_memtype_name[] = { [GSM0705_MEMTYPE_NONE] = "NONE", @@ -431,9 +432,10 @@ static int cmt_parse(const char *buf, int len, const char *param, { /* TODO: TEXT mode */ u_int8_t pdu[SMS_MAX_PDU_SIZE]; - const char *comma = strchr(param, ','); - char *cr; + const char *cr = NULL; int i; + char tmp[64]; + struct gsm_extrsp *er; struct gsmd_evt_auxdata *aux; struct gsmd_sms_list *msg; struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, @@ -446,14 +448,43 @@ static int cmt_parse(const char *buf, int len, const char *param, aux = (struct gsmd_evt_auxdata *) ucmd->buf; msg = (struct gsmd_sms_list *) aux->data; - if (!comma) { + cr = strchr(param, '\n'); + + if (!cr) { talloc_free(ucmd); - return -EINVAL; + return -EAGAIN; } - len = strtoul(comma + 1, &cr, 10); - if (cr[0] != '\n') { + + strncpy(tmp, param, (cr-param)); + tmp[(cr-param)] = '\0'; + + er = extrsp_parse(gsmd_tallocs, tmp); + + if ( !er ) { talloc_free(ucmd); - return -EAGAIN; + return -ENOMEM; + } + + //extrsp_dump(er); + + if ( er->num_tokens == 2 && + er->tokens[0].type == GSMD_ECMD_RTT_EMPTY && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + + aux->u.sms.alpha[0] = '\0'; + len = er->tokens[1].u.numeric; + } + else if ( er->num_tokens == 2 && + er->tokens[0].type == GSMD_ECMD_RTT_STRING && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + + strcpy(aux->u.sms.alpha, er->tokens[0].u.string); + len = er->tokens[1].u.numeric; + } + else { + talloc_free(ucmd); + talloc_free(er); + return -EINVAL; } cr ++; |