rbouqueau / gpac

GPAC mirror from the SourceForge Subversion
GNU Lesser General Public License v2.1
0 stars 1 forks source link

[Bug] mp4box ac3 import unterminated loop on partial last sample [sf#304] #304

Open rbouqueau opened 10 years ago

rbouqueau commented 10 years ago

Reported by ryanseghers on 2014-03-09 22:21 UTC mp4box never finishes importing ac3 file for a certain ac3 file.

In media_import.c gf_import_ac3() the while loop runs forever on certain ac3 files. This happens because the bitstream length - position is less than sample->dataLength, so gf_bs_read_data() does not read anything from the stream so it does not advance the position, yet there are > 6 bytes left in the bitstream, so the loop never terminates. Apparently my ac3 ends with a partial sample, and the code does not handle that case. If the stream position is not advancing then the loop never terminates.

I just created this ac3 file with dgindex. In any case mp4box should probably not hang forever on a bad ac3.

I think the fix is something like break out of the while loop if remaining bytes in bitstream is less than samp->dataLength. Maybe based on return value of 0 from gf_bs_read_data() but there is another case in there that returns 0 so not sure.

rbouqueau commented 10 years ago

Commented by rbouqueau on 2014-03-10 07:59 UTC Hi, thanks for reporting.

Would it be possible to share a sample file with us? You can use wetransfer.com for example (stays alive for one week). And send it via PM if you don't want the URL do be public.

Thanks,

Romain

rbouqueau commented 10 years ago

Commented by ryanseghers on 2014-03-11 04:06 UTC Hi Romain,

I used WeTransfer to share the file with you. Please let me know if you have any trouble with it.

Ryan

On Mon, Mar 10, 2014 at 12:59 AM, Romain Bouqueau rbouqueau@users.sf.netwrote:

Hi, thanks for reporting.

Would it be possible to share a sample file with us? You can use wetransfer.com for example (stays alive for one week). And send it via PM if you don't want the URL do be public.

Thanks,

Romain

Status: open Group: v1.0 (example) Created: Sun Mar 09, 2014 10:21 PM UTC by RyanS Last Updated: Sun Mar 09, 2014 10:21 PM UTC Owner: nobody

mp4box never finishes importing ac3 file for a certain ac3 file.

In media_import.c gf_import_ac3() the while loop runs forever on certain ac3 files. This happens because the bitstream length - position is less than sample->dataLength, so gf_bs_read_data() does not read anything from the stream so it does not advance the position, yet there are > 6 bytes left in the bitstream, so the loop never terminates. Apparently my ac3 ends with a partial sample, and the code does not handle that case. If the stream position is not advancing then the loop never terminates.

I just created this ac3 file with dgindex. In any case mp4box should probably not hang forever on a bad ac3.

I think the fix is something like break out of the while loop if remaining bytes in bitstream is less than samp->dataLength. Maybe based on return value of 0 from gf_bs_read_data() but there is another case in there that

returns 0 so not sure.

Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gpac/bugs/304/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/