diff options
author | Arron Wang <arron.wang@intel.com> | 2014-07-07 14:17:55 +0800 |
---|---|---|
committer | Arron Wang <arron.wang@intel.com> | 2014-07-07 14:18:09 +0800 |
commit | ac694692b7c658230610cee0e9e25012fed6c99f (patch) | |
tree | 0905aa9250b3a60fda5ac9c621cfd396b1cdd230 | |
parent | bde9e9a0d668804b0501647f42f38f8b29ad7542 (diff) | |
download | nfc-manager-neard-accepted/tizen_3.0.m14.3_ivi.tar.gz nfc-manager-neard-accepted/tizen_3.0.m14.3_ivi.tar.bz2 nfc-manager-neard-accepted/tizen_3.0.m14.3_ivi.zip |
Fixed failed to handle empty tag issuetizen_3.0.m14.3_ivi_releasetizen_3.0.2014.q3_common_releasesubmit/tizen_ivi/20140729.000000submit/tizen/20140721.062718accepted/tizen/ivi/20140729.134623accepted/tizen/common/20140724.002300tizen_3.0.m14.3_ivitizen_3.0.2014.q3_commonaccepted/tizen_3.0.m14.3_iviaccepted/tizen_3.0.2014.q3_common
Some NFC tag has empty record, we should also handle
them properly and allow use the write new data to it
Fixed TC-173
Change-Id: I26c712ec0939ee82a6a154865412d5c1f9411aaa
-rw-r--r-- | client/net_nfc_client_ndef_message.c | 2 | ||||
-rw-r--r-- | client/net_nfc_neard.c | 9 | ||||
-rw-r--r-- | common/net_nfc_util_ndef_message.c | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/client/net_nfc_client_ndef_message.c b/client/net_nfc_client_ndef_message.c index 7f561a9..4634f1b 100644 --- a/client/net_nfc_client_ndef_message.c +++ b/client/net_nfc_client_ndef_message.c @@ -91,7 +91,7 @@ API net_nfc_error_e net_nfc_get_ndef_message_byte_length( RETV_IF(NULL == length, NET_NFC_NULL_PARAMETER); *length = net_nfc_util_get_ndef_message_length(ndef_message); - if (*length > 0) + if (*length >= 0) result = NET_NFC_OK; else result = NET_NFC_INVALID_PARAM; diff --git a/client/net_nfc_neard.c b/client/net_nfc_neard.c index c2eafe1..ed3bee8 100644 --- a/client/net_nfc_neard.c +++ b/client/net_nfc_neard.c @@ -303,7 +303,7 @@ static void _tag_found_cb(const char *tagName, void *user_data) if (neardal_get_tag_properties(tagName, &tag) != NEARDAL_SUCCESS) return; - if (tag == NULL || tag->records == NULL) + if (tag == NULL) return; net_nfc_manager_util_play_sound(NET_NFC_TASK_START); @@ -425,7 +425,7 @@ static void _read_completed_cb(GVariant *ret, void *user_data) rawNDEF->length = (int)length; rawNDEF->buffer = g_try_malloc0(rawNDEF->length); - if (rawNDEF->buffer == NULL) { + if (rawNDEF->length > 0 && rawNDEF->buffer == NULL) { g_free(rawNDEF); goto exit; } @@ -768,7 +768,10 @@ net_nfc_error_e net_nfc_neard_write_ndef(net_nfc_target_handle_s *handle, if (record == NULL) return NET_NFC_ALLOC_FAIL; - record->name = g_strdup(tag->records[0]); + if (tag->records != NULL) + record->name = g_strdup(tag->records[0]); + else + record->name = g_strdup(tag->name); record->type = g_strdup("Raw"); record->rawNDEF = g_try_malloc0(data->length); if (record->rawNDEF == NULL) { diff --git a/common/net_nfc_util_ndef_message.c b/common/net_nfc_util_ndef_message.c index 1bbb629..35f254e 100644 --- a/common/net_nfc_util_ndef_message.c +++ b/common/net_nfc_util_ndef_message.c @@ -35,7 +35,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message( RETV_IF(NULL == ndef, NET_NFC_NULL_PARAMETER); RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER); - RETV_IF(rawdata->length < 3, NET_NFC_INVALID_FORMAT); + RETV_IF(rawdata->length < 0, NET_NFC_INVALID_FORMAT); current = rawdata->buffer; last = current + rawdata->length; @@ -200,7 +200,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message( ndef->recordCount++; - if((current != last) || ((ndef_header & NET_NFC_NDEF_RECORD_MASK_ME) == 0)) + if((current != last) || (((ndef_header & NET_NFC_NDEF_RECORD_MASK_ME) == 0) && (rawdata->length != 0))) { result = NET_NFC_INVALID_FORMAT; goto error; |