diff options
author | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-03-25 10:33:45 +0000 |
---|---|---|
committer | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-03-25 10:33:45 +0000 |
commit | a5668a610b1ff9d2196ef11aeb3f4633dda22dd7 (patch) | |
tree | 28ec46bfc1a1f52e28d5e83dfded0e41b94c4eef /src/gsmd | |
parent | 233f48b64d5224e97f310628400d015b4e631a03 (diff) |
gsmd: fix clip & colp parser problem (Erin Yueh)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@4245 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd')
-rw-r--r-- | src/gsmd/unsolicited.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/gsmd/unsolicited.c b/src/gsmd/unsolicited.c index 537e16a..97d4b55 100644 --- a/src/gsmd/unsolicited.c +++ b/src/gsmd/unsolicited.c @@ -348,23 +348,31 @@ static int clip_parse(const char *buf, int len, const char *param, struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_CLIP, sizeof(struct gsmd_evt_auxdata)); struct gsmd_evt_auxdata *aux; - const char *comma = strchr(param, ','); + struct gsm_extrsp *er; - if (!ucmd) + if (!ucmd) return -ENOMEM; aux = (struct gsmd_evt_auxdata *) ucmd->buf; - if (!comma) - return -EINVAL; + er = extrsp_parse(gsmd_tallocs, param); - - if (comma - param > GSMD_ADDR_MAXLEN) - return -EINVAL; + if ( !er ) + return -ENOMEM; - aux->u.clip.addr.number[0] = '\0'; - strncat(aux->u.clip.addr.number, param, comma-param); - /* FIXME: parse of subaddr, etc. */ + if ( er->num_tokens >= 2 && + er->tokens[0].type == GSMD_ECMD_RTT_STRING && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + /* + * <number>,<type>[,<subaddr>,<satype>[,[<alpha>][,<CLI validity>]]] + */ + + strcpy(aux->u.clip.addr.number, er->tokens[0].u.string); + aux->u.clip.addr.type = er->tokens[1].u.numeric; + } else { + DEBUGP("Invalid Input : Parse error\n"); + return -EINVAL; + } return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CLIP); } @@ -376,23 +384,32 @@ static int colp_parse(const char *buf, int len, const char *param, struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_OUT_COLP, sizeof(struct gsmd_evt_auxdata)); struct gsmd_evt_auxdata *aux; - const char *comma = strchr(param, ','); + struct gsm_extrsp *er; if (!ucmd) return -ENOMEM; aux = (struct gsmd_evt_auxdata *) ucmd->buf; - if (!comma) - return -EINVAL; - - if (comma - param > GSMD_ADDR_MAXLEN) - return -EINVAL; + er = extrsp_parse(gsmd_tallocs, param); - aux->u.colp.addr.number[0] = '\0'; - strncat(aux->u.colp.addr.number, param, comma-param); - /* FIXME: parse of subaddr, etc. */ + if ( !er ) + return -ENOMEM; + if ( er->num_tokens >= 2 && + er->tokens[0].type == GSMD_ECMD_RTT_STRING && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + /* + * <number>,<type>[,<subaddr>,<satype> [,<alpha>]] + */ + + strcpy(aux->u.colp.addr.number, er->tokens[0].u.string); + aux->u.colp.addr.type = er->tokens[1].u.numeric; + } else { + DEBUGP("Invalid Input : Parse error\n"); + return -EINVAL; + } + return usock_evt_send(gsmd, ucmd, GSMD_EVT_OUT_COLP); } |