diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2011-11-01 16:28:08 +0100 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2011-11-13 20:25:19 +0100 |
commit | 4d13b401aef49da34e6cd9f27118e2ba9cd5b077 (patch) | |
tree | e634e5785156fd02c0fae01b6af500bc7a6dfc0a /src | |
parent | de4f00d9316006333a4a9454d000463c5480b3d5 (diff) |
host/layer23: SIM client now supports reading records correctly
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/host/layer23/src/common/sim.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 3aca6937..8c89cf0b 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -1045,8 +1045,25 @@ int sim_apdu_resp(struct osmocom_ms *ms, struct msgb *msg) ntohs(ef->file_id), sim->file); goto sim_error; } - /* get length of file */ - ef_len = ntohs(ef->file_size); + /* check for record */ + if (length >= 15 && ef->length >= 2 && ef->structure != 0x00) { + /* get length of record */ + ef_len = ntohs(ef->file_size); + if (ef_len < data[14]) { + LOGP(DSIM, LOGL_NOTICE, "total length is " + "smaller (%d) than record size (%d)\n", + ef_len, data[14]); + goto request_error; + } + ef_len = data[14]; + LOGP(DSIM, LOGL_NOTICE, "selected record (len %d " + "structure %d)\n", ef_len, ef->structure); + } else { + /* get length of file */ + ef_len = ntohs(ef->file_size); + LOGP(DSIM, LOGL_NOTICE, "selected file (len %d)\n", + ef_len); + } /* do file command */ sim->job_state = SIM_JST_WAIT_FILE; switch (sh->job_type) { |