Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-31950

Parsing a multi-record tag into an NDEF message doesn't reset data for each record

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.0
    • 5.2.0
    • Connectivity: NFC
    • None

    Description

      Preparations (or just take a look at the proposed solution and the code, and it'll make sense): Create an NDEF message that contains multiple records. The first record contains a payload (e.g., length = 10), the second doesn't contain a payload (length = 0).

      Write this NDEF message to a tag (or convert it into a byte array).

      Now read the byte array into a message using QNdefMessage::fromByteArray()

      Expected outcome: the records are the same that were initially put into the message.

      Actual outcome: the created records contain wrong data. The first record is fine, but the second also the payload set to length = 10 (instead of length = 0, as should be the case.

      Reason: The loop that parses the NDEF message doesn't reset the data in the "record" variable after a record has been constructed and the loop moves on to the next record.
      This means that if the first record sets specific data (like the payload, ID, etc.) and the second record doesn't override it, the data of the first record will still be present in the second record.

      Proposed solution: Change lines 215+ of qndefmessage.cpp from:

      if (!cf) {
      result.append(record);
      }

      To:

      if (!cf) {
      result.append(record);
      record = QNdefRecord();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ablasche Alex Blasche
            ajakl Andreas Jakl (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes