Skip to content

Incorrect parsing of UTF-16 in ID3 frames #1774

@cbfiddle

Description

@cbfiddle

The end of string detection (introduced for issue 324) looks for a pair of zero bytes. It should look for a pair of zero bytes starting at an even index, otherwise it will incorrectly parse a string whose last character encoding ends with a 0 byte.

Suggested change to Id3Parser.indexOfEos:

    // Otherwise ensure an even index and look for a second zero byte.
    while (terminationPos < data.length - 1) {
      if (terminationPos % 2 == 0 && data[terminationPos + 1] == (byte) 0) {
        return terminationPos;
      }
      terminationPos = indexOfZeroByte(data, terminationPos + 1);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions