nfctype2: Get the actual tag data length when trying to write an NDEF
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 15 Mar 2013 19:53:20 +0000 (20:53 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 15 Mar 2013 19:53:20 +0000 (20:53 +0100)
plugins/nfctype2.c

index 51e2056..15fd046 100644 (file)
@@ -436,8 +436,10 @@ static int nfctype2_write(uint32_t adapter_idx, uint32_t target_idx,
                 * including TLV's is NDEF_MAX_SIZE
                 */
                if (near_tag_get_memory_layout(tag) == NEAR_TAG_MEMORY_STATIC) {
-                       if ((ndef->length + 3) > NDEF_MAX_SIZE) {
-                               near_error("not enough space on tag");
+                       if ((ndef->length + 3) > near_tag_get_data_length(tag)) {
+                               near_error("Not enough space on tag %zd %zd",
+                                               ndef->length,
+                                               near_tag_get_data_length(tag));
                                err = -ENOSPC;
                                goto out_err;
                        }