diff options
author | Mark A. Greer <mgreer@animalcreek.com> | 2014-03-20 17:32:02 -0700 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-04-07 01:21:28 +0200 |
commit | 8181a18ec9e5ab827cd5465a63cf5b71e3b7c25a (patch) | |
tree | 63164d9a95dd7f579c3a47ad96da8875111dc139 | |
parent | e3f64e7f81b1bc55282e62dc82b4d3c6b8146bdc (diff) | |
download | neard-8181a18ec9e5ab827cd5465a63cf5b71e3b7c25a.tar.gz neard-8181a18ec9e5ab827cd5465a63cf5b71e3b7c25a.tar.bz2 neard-8181a18ec9e5ab827cd5465a63cf5b71e3b7c25a.zip |
nfctype4: Read the proper number of byte of the NDEF file
When reading the NDEF file from the tag, the t4_readbin_NDEF_ID()
routine reads "Max R-APDU Data Size" bytes instead of the number of
bytes in the NDEF file. Fix this by reading the number of bytes in
the NDEF file which is available in the response data passed into
t4_readbin_NDEF_ID().
-rw-r--r-- | plugins/nfctype4.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/nfctype4.c b/plugins/nfctype4.c index b7bb1bc..109d725 100644 --- a/plugins/nfctype4.c +++ b/plugins/nfctype4.c @@ -351,6 +351,7 @@ static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) { struct t4_cookie *cookie = data; struct near_tag *tag = cookie->tag; + size_t data_length; int err; DBG("%d", length); @@ -364,9 +365,11 @@ static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) return t4_cookie_release(-EIO, cookie); } + data_length = near_get_be16(resp + NFC_STATUS_BYTE_LEN); + /* Add data to the tag */ err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, NULL, - near_get_be16(resp + NFC_STATUS_BYTE_LEN)); + data_length); if (err < 0) return t4_cookie_release(err, cookie); @@ -384,8 +387,7 @@ static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) */ /* Read 1st block */ - return ISO_ReadBinary(2, cookie->r_apdu_max_size - 2, - data_read_cb, cookie); + return ISO_ReadBinary(2, data_length, data_read_cb, cookie); } static int t4_get_file_len(struct t4_cookie *cookie) |