@@ -67,12 +67,19 @@ public function Analyze() {
6767 $ RIFFsize = substr ($ RIFFheader , 4 , 4 );
6868 $ RIFFsubtype = substr ($ RIFFheader , 8 , 4 );
6969
70- switch ($ RIFFtype ) {
70+ if ($ RIFFsize == "\x00\x00\x00\x00" ) {
71+ // https://github.com/JamesHeinrich/getID3/issues/468
72+ // may occur in streaming files where the data size is unknown
73+ $ thisfile_riff ['header_size ' ] = $ info ['avdataend ' ] - 8 ;
74+ $ this ->warning ('RIFF size field is empty, assuming the correct value is filesize-8 ( ' .$ thisfile_riff ['header_size ' ].') ' );
75+ } else {
76+ $ thisfile_riff ['header_size ' ] = $ this ->EitherEndian2Int ($ RIFFsize );
77+ }
7178
79+ switch ($ RIFFtype ) {
7280 case 'FORM ' : // AIFF, AIFC
7381 //$info['fileformat'] = 'aiff';
7482 $ this ->container = 'aiff ' ;
75- $ thisfile_riff ['header_size ' ] = $ this ->EitherEndian2Int ($ RIFFsize );
7683 $ thisfile_riff [$ RIFFsubtype ] = $ this ->ParseRIFF ($ offset , ($ offset + $ thisfile_riff ['header_size ' ] - 4 ));
7784 break ;
7885
@@ -81,7 +88,6 @@ public function Analyze() {
8188 case 'RMP3 ' : // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
8289 //$info['fileformat'] = 'riff';
8390 $ this ->container = 'riff ' ;
84- $ thisfile_riff ['header_size ' ] = $ this ->EitherEndian2Int ($ RIFFsize );
8591 if ($ RIFFsubtype == 'RMP3 ' ) {
8692 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
8793 $ RIFFsubtype = 'WAVE ' ;
@@ -1606,9 +1612,18 @@ public function ParseRIFF($startoffset, $maxoffset) {
16061612 $ this ->error ('Expecting chunk name at offset ' .($ this ->ftell () - 8 ).' but found nothing. Aborting RIFF parsing. ' );
16071613 break ;
16081614 }
1609- if (($ chunksize == 0 ) && ($ chunkname != 'JUNK ' )) {
1610- $ this ->warning ('Chunk ( ' .$ chunkname .') size at offset ' .($ this ->ftell () - 4 ).' is zero. Aborting RIFF parsing. ' );
1611- break ;
1615+ if ($ chunksize == 0 ) {
1616+ if ($ chunkname == 'JUNK ' ) {
1617+ // this is allowed
1618+ } elseif ($ chunkname == 'data ' ) {
1619+ // https://github.com/JamesHeinrich/getID3/issues/468
1620+ // may occur in streaming files where the data size is unknown
1621+ $ chunksize = $ info ['avdataend ' ] - $ this ->ftell ();
1622+ $ this ->warning ('RIFF.data size field is empty, assuming the correct value is filesize-offset ( ' .$ chunksize .') ' );
1623+ } else {
1624+ $ this ->warning ('Chunk ( ' .$ chunkname .') size at offset ' .($ this ->ftell () - 4 ).' is zero. Aborting RIFF parsing. ' );
1625+ break ;
1626+ }
16121627 }
16131628 if (($ chunksize % 2 ) != 0 ) {
16141629 // all structures are packed on word boundaries
0 commit comments