dgallegos / edidreader

JavaScript EDID Parser
MIT License
85 stars 14 forks source link

When Audio Data Block length is not a multiple of 3 script crashes #5

Open cepesh opened 7 years ago

cepesh commented 7 years ago

I've come across an EDID that crashes the script. It has two ADBs and one of them has a length of 1. 00 FF FF FF FF FF FF 00 4C 2D 01 0C 01 00 00 01 2A 18 01 03 80 69 3B 78 0A 23 AD A4 54 4D 99 26 0F 47 4A BD EF 80 71 4F 81 C0 81 00 81 80 95 00 A9 C0 B3 00 01 01 08 E8 00 30 F2 70 5A 80 B0 58 8A 00 50 1D 74 00 00 1E 02 3A 80 18 71 38 2D 40 58 2C 45 00 50 1D 74 00 00 1E 00 00 00 FD 00 18 4B 0F 87 3C 00 0A 20 20 20 20 20 20 00 00 00 FC 00 53 41 4D 53 55 4E 47 0A 20 20 20 20 20 01 5C 02 03 58 F1 57 61 10 1F 04 13 05 14 20 21 22 5D 5E 5F 60 65 66 62 63 64 07 16 03 12 29 09 07 07 15 07 50 3D 04 C0 83 01 00 00 E2 00 01 21 05 C0 00 76 03 0C 00 10 00 B8 3C 21 D0 88 01 02 03 04 01 40 3F FF 50 60 80 90 67 D8 5D C4 01 78 80 03 E3 06 05 01 E3 0F 01 E0 01 1D 80 D0 72 1C 16 20 10 2C 25 80 50 1D 74 00 00 9E 66 21 56 AA 51 00 1E 30 46 8F 33 00 50 1D 74 00 00 1E 00 00 00 A6

RangeError: Invalid array length
    at Edid.parseAudioDataBlock (edid.js:850)
    at Edid.parseDataBlockCollection (edid.js:806)
    at Edid.parse (edid.js:242)
    at a.EdidCtrl.$scope.parseEdid (controllers.js:142)
    at angular.min.js:72
    at a.$eval (angular.min.js:88)
    at a.$apply (angular.min.js:88)
    at HTMLFormElement.<anonymous> (angular.min.js:144)
    at HTMLFormElement.dispatch (jquery.min.js:2)
    at HTMLFormElement.u (jquery.min.js:2)
dgallegos commented 7 years ago

I haven't look at this EDID yet, but Audio Data Blocks should be 3 byte descriptors. Unless there is a CEA-861 update that I'm not up to date on. The last CEA-861 standard I had was -E or -F. I'll need to see if I can get my hands on an updated standard to update the site correctly.

cepesh commented 7 years ago

Nope, one would hope that this block has a length that is a multiple of 3 bytes, however, rightly or wrongly, EDID above has two Audio Blocks and one of them has the length specified as 1 byte. This breaks the parsing because you're allocating a fractional value to an array size.