Skip to content

Commit

Permalink
Fix max length used when reading strings on APIC
Browse files Browse the repository at this point in the history
When reading the format or description of the APIC it could fail because we were trying to read one byte too many.

No unit test because I need a different type of ArrayFileReader, one that fails when trying to read data that wasn't previously loaded.

Fix #22
  • Loading branch information
aadsm committed May 5, 2016
1 parent 54b5cb4 commit 8e21053
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/jsmediatags.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ frameReaderFunctions['APIC'] = function readPictureFrame(offset, length, data, f

case '3':
case '4':
var format = data.getStringWithCharsetAt(offset + 1, length - (offset - start));
var format = data.getStringWithCharsetAt(offset + 1, length - 1);
offset += 1 + format.bytesReadCount;
break;

Expand All @@ -501,7 +501,7 @@ frameReaderFunctions['APIC'] = function readPictureFrame(offset, length, data, f
}
var bite = data.getByteAt(offset, 1);
var type = PICTURE_TYPE[bite];
var desc = data.getStringWithCharsetAt(offset + 1, length - (offset - start), charset);
var desc = data.getStringWithCharsetAt(offset + 1, length - (offset - start) - 1, charset);

offset += 1 + desc.bytesReadCount;

Expand Down
Loading

0 comments on commit 8e21053

Please sign in to comment.