nfctool: sniffer: Fix ndef read-ahead check macro
authorThierry Escande <thierry.escande@linux.intel.com>
Tue, 25 Jun 2013 13:41:09 +0000 (15:41 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 25 Jun 2013 14:32:08 +0000 (16:32 +0200)
This macro checks if we can safely read the next field in a ndef
record. So the check needs to be done at the current read position
in the current record.

tools/nfctool/ndef-decode.c

index 72f250b..bc891ae 100644 (file)
@@ -226,7 +226,7 @@ int ndef_print_records(guint8 *data, guint32 data_len)
 
 #define CHECK_OFFSET(s)                                                        \
        do {                                                            \
-               if (data_len - ndef_offset < (s)) {                     \
+               if (data_len - (ndef_offset + record_offset) < (s)) {   \
                        ndef_printf_error("Malformed NDEF record");     \
                        sniffer_print_hexdump(stdout, data, data_len,   \
                                              NDEF_HEX_INDENT, TRUE);   \