diff mbox series

[FFmpeg-devel] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel)

Message ID 928dcb75-6411-4e33-caa8-5cd247f8a185@ektacom.com
State New
Headers show
Series [FFmpeg-devel] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel) | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Cédric Le Barz March 8, 2023, 3:55 p.m. UTC
Fix issue when invalid nb_index_entries value is read : in case of false 
nb_index_entries value, ffmpeg exit. This patch fix this problem.


Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
---
  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

          segment->flag_entries[i] = avio_r8(pb);

Comments

Marton Balint March 8, 2023, 10:05 p.m. UTC | #1
On Wed, 8 Mar 2023, Cédric Le Barz wrote:

>
> Fix issue when invalid nb_index_entries value is read : in case of false 
> nb_index_entries value, ffmpeg exit. This patch fix this problem.

What do you mean invalid? Is the value wrong, or is the file truncated in 
the middle of the index segment? From the patch it looks like the latter.

Is there a single unluckily truncated file that you want to fix with this 
patch, or multiple files can be affected by this fix because e.g. they 
are written by the same broken muxer?

Overall I am not sure if we want this applied, the user can also opt to 
avoid parsing all partitions with -seekable 0 and read / remux the file 
sequentially ignoring any index, so if somebody wants to rescue the data, 
it can be done as is.

Regards,
Marton

>
>
> Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
> ---
>  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c
> index 4530617..ffc8987 100644
> --- a/ffmpeg/libavformat/mxfdec.c
> +++ b/ffmpeg/libavformat/mxfdec.c
> @@ -1221,8 +1221,18 @@ static int mxf_read_index_entry_array(AVIOContext *pb, 
> MXFIndexTableSegment *seg
>      }
>      for (i = 0; i < segment->nb_index_entries; i++) {
> -        if(avio_feof(pb))
> -            return AVERROR_INVALIDDATA;
> +
> +        if(avio_feof(pb)) {
> +            if (i == 0) {
> +                return AVERROR_INVALIDDATA;
> +            } else {
> +                /* To be more robust to invalid nb_index_entries value,
> +                   fix the index entry number according to read entries */
> +                segment->nb_index_entries = i;
> +                return 0;
> +            }
> +        }
> +
>          segment->temporal_offset_entries[i] = avio_r8(pb);
>          avio_r8(pb);                                        /* 
> KeyFrameOffset */
>         segment->flag_entries[i] = avio_r8(pb);
> -- 
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
Cédric Le Barz March 16, 2023, 9:45 a.m. UTC | #2
Hi,

By "invalid", I mean that the written nb_index_entries value does not match with the real number of entries in the table. The number of entries in the table is lower than the specified one. This is a bug in commercial MXFTk software (at least version V 2.8.0.0.1). It exists a lot a MXF files with this problem. 

Best regards,

Cédric

-----Message d'origine-----
De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de Marton Balint
Envoyé : mercredi 8 mars 2023 23:06
À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel)



On Wed, 8 Mar 2023, Cédric Le Barz wrote:

>
> Fix issue when invalid nb_index_entries value is read : in case of 
> false nb_index_entries value, ffmpeg exit. This patch fix this problem.

What do you mean invalid? Is the value wrong, or is the file truncated in the middle of the index segment? From the patch it looks like the latter.

Is there a single unluckily truncated file that you want to fix with this patch, or multiple files can be affected by this fix because e.g. they are written by the same broken muxer?

Overall I am not sure if we want this applied, the user can also opt to avoid parsing all partitions with -seekable 0 and read / remux the file sequentially ignoring any index, so if somebody wants to rescue the data, it can be done as is.

Regards,
Marton

>
>
> Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
> ---
>  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c 
> index 4530617..ffc8987 100644
> --- a/ffmpeg/libavformat/mxfdec.c
> +++ b/ffmpeg/libavformat/mxfdec.c
> @@ -1221,8 +1221,18 @@ static int 
> mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>      }
>      for (i = 0; i < segment->nb_index_entries; i++) {
> -        if(avio_feof(pb))
> -            return AVERROR_INVALIDDATA;
> +
> +        if(avio_feof(pb)) {
> +            if (i == 0) {
> +                return AVERROR_INVALIDDATA;
> +            } else {
> +                /* To be more robust to invalid nb_index_entries value,
> +                   fix the index entry number according to read entries */
> +                segment->nb_index_entries = i;
> +                return 0;
> +            }
> +        }
> +
>          segment->temporal_offset_entries[i] = avio_r8(pb);
>          avio_r8(pb);                                        /* 
> KeyFrameOffset */
>         segment->flag_entries[i] = avio_r8(pb);
> --
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email 
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
Cédric Le Barz March 16, 2023, 1:33 p.m. UTC | #3
Hi,

By "invalid", I mean that the written nb_index_entries value does not match with the real number of entries in the table. The number of entries in the table is lower than the specified one. This is a bug in commercial MXFTk software (at least version V 2.8.0.0.1) : it exists a lot a MXF files with this problem.  The proposed patch just robustify index table parsing.

Best regards,

Cédric

-----Message d'origine-----
De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de Marton Balint
Envoyé : mercredi 8 mars 2023 23:06
À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel)



On Wed, 8 Mar 2023, Cédric Le Barz wrote:

>
> Fix issue when invalid nb_index_entries value is read : in case of 
> false nb_index_entries value, ffmpeg exit. This patch fix this problem.

What do you mean invalid? Is the value wrong, or is the file truncated in the middle of the index segment? From the patch it looks like the latter.

Is there a single unluckily truncated file that you want to fix with this patch, or multiple files can be affected by this fix because e.g. they are written by the same broken muxer?

Overall I am not sure if we want this applied, the user can also opt to avoid parsing all partitions with -seekable 0 and read / remux the file sequentially ignoring any index, so if somebody wants to rescue the data, it can be done as is.

Regards,
Marton

>
>
> Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
> ---
>  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c 
> index 4530617..ffc8987 100644
> --- a/ffmpeg/libavformat/mxfdec.c
> +++ b/ffmpeg/libavformat/mxfdec.c
> @@ -1221,8 +1221,18 @@ static int 
> mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>      }
>      for (i = 0; i < segment->nb_index_entries; i++) {
> -        if(avio_feof(pb))
> -            return AVERROR_INVALIDDATA;
> +
> +        if(avio_feof(pb)) {
> +            if (i == 0) {
> +                return AVERROR_INVALIDDATA;
> +            } else {
> +                /* To be more robust to invalid nb_index_entries value,
> +                   fix the index entry number according to read entries */
> +                segment->nb_index_entries = i;
> +                return 0;
> +            }
> +        }
> +
>          segment->temporal_offset_entries[i] = avio_r8(pb);
>          avio_r8(pb);                                        /* 
> KeyFrameOffset */
>         segment->flag_entries[i] = avio_r8(pb);
> --
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email 
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
Marton Balint March 16, 2023, 8:28 p.m. UTC | #4
On Thu, 16 Mar 2023, Cédric Le Barz wrote:

> Hi,
>
> By "invalid", I mean that the written nb_index_entries value does not 
> match with the real number of entries in the table. The number of 
> entries in the table is lower than the specified one. This is a bug in 
> commercial MXFTk software (at least version V 2.8.0.0.1). It exists a 
> lot a MXF files with this problem.

Please share a sample. Or better yet, open a ticket for this issue and 
attach a sample there for future reference.

Thanks,
Marton

>
> Best regards,
>
> Cédric
>
> -----Message d'origine-----
> De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de Marton Balint
> Envoyé : mercredi 8 mars 2023 23:06
> À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel)
>
>
>
> On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>
>>
>> Fix issue when invalid nb_index_entries value is read : in case of 
>> false nb_index_entries value, ffmpeg exit. This patch fix this problem.
>
> What do you mean invalid? Is the value wrong, or is the file truncated in the middle of the index segment? From the patch it looks like the latter.
>
> Is there a single unluckily truncated file that you want to fix with this patch, or multiple files can be affected by this fix because e.g. they are written by the same broken muxer?
>
> Overall I am not sure if we want this applied, the user can also opt to avoid parsing all partitions with -seekable 0 and read / remux the file sequentially ignoring any index, so if somebody wants to rescue the data, it can be done as is.
>
> Regards,
> Marton
>
>>
>>
>> Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>> ---
>>  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c 
>> index 4530617..ffc8987 100644
>> --- a/ffmpeg/libavformat/mxfdec.c
>> +++ b/ffmpeg/libavformat/mxfdec.c
>> @@ -1221,8 +1221,18 @@ static int 
>> mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>>      }
>>      for (i = 0; i < segment->nb_index_entries; i++) {
>> -        if(avio_feof(pb))
>> -            return AVERROR_INVALIDDATA;
>> +
>> +        if(avio_feof(pb)) {
>> +            if (i == 0) {
>> +                return AVERROR_INVALIDDATA;
>> +            } else {
>> +                /* To be more robust to invalid nb_index_entries value,
>> +                   fix the index entry number according to read entries */
>> +                segment->nb_index_entries = i;
>> +                return 0;
>> +            }
>> +        }
>> +
>>          segment->temporal_offset_entries[i] = avio_r8(pb);
>>          avio_r8(pb);                                        /* 
>> KeyFrameOffset */
>>         segment->flag_entries[i] = avio_r8(pb);
>> --
>> 2.34.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email 
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Cédric Le Barz March 20, 2023, 3:52 p.m. UTC | #5
We have several samples but these are big files: about 7 GB. Is it OK to 
share such a file size ?

Thanks for you answer,

Regards,

Cédric

Le 16/03/2023 à 21:28, Marton Balint a écrit :
>
>
> On Thu, 16 Mar 2023, Cédric Le Barz wrote:
>
>> Hi,
>>
>> By "invalid", I mean that the written nb_index_entries value does not
>> match with the real number of entries in the table. The number of
>> entries in the table is lower than the specified one. This is a bug in
>> commercial MXFTk software (at least version V 2.8.0.0.1). It exists a
>> lot a MXF files with this problem.
>
> Please share a sample. Or better yet, open a ticket for this issue and
> attach a sample there for future reference.
>
> Thanks,
> Marton
>
>>
>> Best regards,
>>
>> Cédric
>>
>> -----Message d'origine-----
>> De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de 
>> Marton Balint
>> Envoyé : mercredi 8 mars 2023 23:06
>> À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
>> Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid 
>> nb_index_entries value is read - SPONSORED BY INA (Institut National 
>> de l'Audiovisuel)
>>
>>
>>
>> On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>>
>>>
>>> Fix issue when invalid nb_index_entries value is read : in case of
>>> false nb_index_entries value, ffmpeg exit. This patch fix this problem.
>>
>> What do you mean invalid? Is the value wrong, or is the file 
>> truncated in the middle of the index segment? From the patch it looks 
>> like the latter.
>>
>> Is there a single unluckily truncated file that you want to fix with 
>> this patch, or multiple files can be affected by this fix because 
>> e.g. they are written by the same broken muxer?
>>
>> Overall I am not sure if we want this applied, the user can also opt 
>> to avoid parsing all partitions with -seekable 0 and read / remux the 
>> file sequentially ignoring any index, so if somebody wants to rescue 
>> the data, it can be done as is.
>>
>> Regards,
>> Marton
>>
>>>
>>>
>>> Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>>> ---
>>>  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c
>>> index 4530617..ffc8987 100644
>>> --- a/ffmpeg/libavformat/mxfdec.c
>>> +++ b/ffmpeg/libavformat/mxfdec.c
>>> @@ -1221,8 +1221,18 @@ static int
>>> mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>>>      }
>>>      for (i = 0; i < segment->nb_index_entries; i++) {
>>> -        if(avio_feof(pb))
>>> -            return AVERROR_INVALIDDATA;
>>> +
>>> +        if(avio_feof(pb)) {
>>> +            if (i == 0) {
>>> +                return AVERROR_INVALIDDATA;
>>> +            } else {
>>> +                /* To be more robust to invalid nb_index_entries 
>>> value,
>>> +                   fix the index entry number according to read 
>>> entries */
>>> +                segment->nb_index_entries = i;
>>> +                return 0;
>>> +            }
>>> +        }
>>> +
>>>          segment->temporal_offset_entries[i] = avio_r8(pb);
>>>          avio_r8(pb); /*
>>> KeyFrameOffset */
>>>         segment->flag_entries[i] = avio_r8(pb);
>>> -- 
>>> 2.34.1
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>
>>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email 
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marton Balint March 20, 2023, 8:03 p.m. UTC | #6
On Mon, 20 Mar 2023, Cédric Le Barz wrote:

> We have several samples but these are big files: about 7 GB. Is it OK to 
> share such a file size ?

I kind of hoped you have access to the broken muxer and can remux a 
small file which can be made public.

If not, then simply upload it somewhere so I can take a look. If the 
sample can't be made public, just share it with me privately.

Thanks,
Marton

>
> Thanks for you answer,
>
> Regards,
>
> Cédric
>
> Le 16/03/2023 à 21:28, Marton Balint a écrit :
>> 
>>
>>  On Thu, 16 Mar 2023, Cédric Le Barz wrote:
>>
>>>  Hi,
>>>
>>>  By "invalid", I mean that the written nb_index_entries value does not
>>>  match with the real number of entries in the table. The number of
>>>  entries in the table is lower than the specified one. This is a bug in
>>>  commercial MXFTk software (at least version V 2.8.0.0.1). It exists a
>>>  lot a MXF files with this problem.
>>
>>  Please share a sample. Or better yet, open a ticket for this issue and
>>  attach a sample there for future reference.
>>
>>  Thanks,
>>  Marton
>> 
>>>
>>>  Best regards,
>>>
>>>  Cédric
>>>
>>>  -----Message d'origine-----
>>>  De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de Marton
>>>  Balint
>>>  Envoyé : mercredi 8 mars 2023 23:06
>>>  À : FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
>>>  Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid
>>>  nb_index_entries value is read - SPONSORED BY INA (Institut National de
>>>  l'Audiovisuel)
>>> 
>>> 
>>>
>>>  On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>>> 
>>>>
>>>>  Fix issue when invalid nb_index_entries value is read : in case of
>>>>  false nb_index_entries value, ffmpeg exit. This patch fix this problem.
>>>
>>>  What do you mean invalid? Is the value wrong, or is the file truncated in
>>>  the middle of the index segment? From the patch it looks like the latter.
>>>
>>>  Is there a single unluckily truncated file that you want to fix with this
>>>  patch, or multiple files can be affected by this fix because e.g. they
>>>  are written by the same broken muxer?
>>>
>>>  Overall I am not sure if we want this applied, the user can also opt to
>>>  avoid parsing all partitions with -seekable 0 and read / remux the file
>>>  sequentially ignoring any index, so if somebody wants to rescue the data,
>>>  it can be done as is.
>>>
>>>  Regards,
>>>  Marton
>>> 
>>>> 
>>>>
>>>>  Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>>>>  ---
>>>>   ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>>>
>>>>  diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c
>>>>  index 4530617..ffc8987 100644
>>>>  --- a/ffmpeg/libavformat/mxfdec.c
>>>>  +++ b/ffmpeg/libavformat/mxfdec.c
>>>>  @@ -1221,8 +1221,18 @@ static int
>>>>  mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
>>>>       }
>>>>       for (i = 0; i < segment->nb_index_entries; i++) {
>>>>  -        if(avio_feof(pb))
>>>>  -            return AVERROR_INVALIDDATA;
>>>>  +
>>>>  +        if(avio_feof(pb)) {
>>>>  +            if (i == 0) {
>>>>  +                return AVERROR_INVALIDDATA;
>>>>  +            } else {
>>>>  +                /* To be more robust to invalid nb_index_entries value,
>>>>  +                   fix the index entry number according to read entries
>>>>  */
>>>>  +                segment->nb_index_entries = i;
>>>>  +                return 0;
>>>>  +            }
>>>>  +        }
>>>>  +
>>>>           segment->temporal_offset_entries[i] = avio_r8(pb);
>>>>           avio_r8(pb); /*
>>>>  KeyFrameOffset */
>>>>          segment->flag_entries[i] = avio_r8(pb);
>>>>  --
>>>>  2.34.1
>>>>
>>>>  _______________________________________________
>>>>  ffmpeg-devel mailing list
>>>>  ffmpeg-devel@ffmpeg.org
>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>  To unsubscribe, visit link above, or email
>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>> 
>>>>
>>>  _______________________________________________
>>>  ffmpeg-devel mailing list
>>>  ffmpeg-devel@ffmpeg.org
>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>  To unsubscribe, visit link above, or email
>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>
>>>  _______________________________________________
>>>  ffmpeg-devel mailing list
>>>  ffmpeg-devel@ffmpeg.org
>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>  To unsubscribe, visit link above, or email
>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>  _______________________________________________
>>  ffmpeg-devel mailing list
>>  ffmpeg-devel@ffmpeg.org
>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>  To unsubscribe, visit link above, or email
>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
Cédric Le Barz March 24, 2023, 9:13 a.m. UTC | #7
Hi Marton,

A sample can be downloaded from here : 
https://estendirectapi.ektacom.com/download/ffmpeg/

Regards,

Cédric


Le 20/03/2023 à 21:03, Marton Balint a écrit :
>
>
> On Mon, 20 Mar 2023, Cédric Le Barz wrote:
>
>> We have several samples but these are big files: about 7 GB. Is it OK to
>> share such a file size ?
>
> I kind of hoped you have access to the broken muxer and can remux a
> small file which can be made public.
>
> If not, then simply upload it somewhere so I can take a look. If the
> sample can't be made public, just share it with me privately.
>
> Thanks,
> Marton
>
>>
>> Thanks for you answer,
>>
>> Regards,
>>
>> Cédric
>>
>> Le 16/03/2023 à 21:28, Marton Balint a écrit :
>>>
>>>
>>>  On Thu, 16 Mar 2023, Cédric Le Barz wrote:
>>>
>>>>  Hi,
>>>>
>>>>  By "invalid", I mean that the written nb_index_entries value does not
>>>>  match with the real number of entries in the table. The number of
>>>>  entries in the table is lower than the specified one. This is a 
>>>> bug in
>>>>  commercial MXFTk software (at least version V 2.8.0.0.1). It exists a
>>>>  lot a MXF files with this problem.
>>>
>>>  Please share a sample. Or better yet, open a ticket for this issue and
>>>  attach a sample there for future reference.
>>>
>>>  Thanks,
>>>  Marton
>>>
>>>>
>>>>  Best regards,
>>>>
>>>>  Cédric
>>>>
>>>>  -----Message d'origine-----
>>>>  De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de 
>>>> Marton
>>>>  Balint
>>>>  Envoyé : mercredi 8 mars 2023 23:06
>>>>  À : FFmpeg development discussions and patches 
>>>> <ffmpeg-devel@ffmpeg.org>
>>>>  Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid
>>>>  nb_index_entries value is read - SPONSORED BY INA (Institut 
>>>> National de
>>>>  l'Audiovisuel)
>>>>
>>>>
>>>>
>>>>  On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>>>>
>>>>>
>>>>>  Fix issue when invalid nb_index_entries value is read : in case of
>>>>>  false nb_index_entries value, ffmpeg exit. This patch fix this 
>>>>> problem.
>>>>
>>>>  What do you mean invalid? Is the value wrong, or is the file 
>>>> truncated in
>>>>  the middle of the index segment? From the patch it looks like the 
>>>> latter.
>>>>
>>>>  Is there a single unluckily truncated file that you want to fix 
>>>> with this
>>>>  patch, or multiple files can be affected by this fix because e.g. 
>>>> they
>>>>  are written by the same broken muxer?
>>>>
>>>>  Overall I am not sure if we want this applied, the user can also 
>>>> opt to
>>>>  avoid parsing all partitions with -seekable 0 and read / remux the 
>>>> file
>>>>  sequentially ignoring any index, so if somebody wants to rescue 
>>>> the data,
>>>>  it can be done as is.
>>>>
>>>>  Regards,
>>>>  Marton
>>>>
>>>>>
>>>>>
>>>>>  Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>>>>>  ---
>>>>>   ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>>>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>>>>
>>>>>  diff --git a/ffmpeg/libavformat/mxfdec.c 
>>>>> b/ffmpeg/libavformat/mxfdec.c
>>>>>  index 4530617..ffc8987 100644
>>>>>  --- a/ffmpeg/libavformat/mxfdec.c
>>>>>  +++ b/ffmpeg/libavformat/mxfdec.c
>>>>>  @@ -1221,8 +1221,18 @@ static int
>>>>>  mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment 
>>>>> *seg
>>>>>       }
>>>>>       for (i = 0; i < segment->nb_index_entries; i++) {
>>>>>  -        if(avio_feof(pb))
>>>>>  -            return AVERROR_INVALIDDATA;
>>>>>  +
>>>>>  +        if(avio_feof(pb)) {
>>>>>  +            if (i == 0) {
>>>>>  +                return AVERROR_INVALIDDATA;
>>>>>  +            } else {
>>>>>  +                /* To be more robust to invalid nb_index_entries 
>>>>> value,
>>>>>  +                   fix the index entry number according to read 
>>>>> entries
>>>>>  */
>>>>>  +                segment->nb_index_entries = i;
>>>>>  +                return 0;
>>>>>  +            }
>>>>>  +        }
>>>>>  +
>>>>>           segment->temporal_offset_entries[i] = avio_r8(pb);
>>>>>           avio_r8(pb); /*
>>>>>  KeyFrameOffset */
>>>>>          segment->flag_entries[i] = avio_r8(pb);
>>>>>  --
>>>>>  2.34.1
>>>>>
>>>>>  _______________________________________________
>>>>>  ffmpeg-devel mailing list
>>>>>  ffmpeg-devel@ffmpeg.org
>>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>>  To unsubscribe, visit link above, or email
>>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>
>>>>>
>>>>  _______________________________________________
>>>>  ffmpeg-devel mailing list
>>>>  ffmpeg-devel@ffmpeg.org
>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>  To unsubscribe, visit link above, or email
>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>
>>>>  _______________________________________________
>>>>  ffmpeg-devel mailing list
>>>>  ffmpeg-devel@ffmpeg.org
>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>  To unsubscribe, visit link above, or email
>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>  _______________________________________________
>>>  ffmpeg-devel mailing list
>>>  ffmpeg-devel@ffmpeg.org
>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>  To unsubscribe, visit link above, or email
>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Cédric Le Barz March 24, 2023, 10:22 a.m. UTC | #8
Hi Marton,

The previous link was not OK, sorry. The good link that will make you 
possible to download the sample is the following : 
https://estendirectapi.ektacom.com/download/ffmpeg/Sample.mxf

Regards,

Cédric


Le 24/03/2023 à 10:13, Cédric Le Barz a écrit :
> Hi Marton,
>
> A sample can be downloaded from here : 
> https://estendirectapi.ektacom.com/download/ffmpeg/
>
> Regards,
>
> Cédric
>
>
> Le 20/03/2023 à 21:03, Marton Balint a écrit :
>>
>>
>> On Mon, 20 Mar 2023, Cédric Le Barz wrote:
>>
>>> We have several samples but these are big files: about 7 GB. Is it 
>>> OK to
>>> share such a file size ?
>>
>> I kind of hoped you have access to the broken muxer and can remux a
>> small file which can be made public.
>>
>> If not, then simply upload it somewhere so I can take a look. If the
>> sample can't be made public, just share it with me privately.
>>
>> Thanks,
>> Marton
>>
>>>
>>> Thanks for you answer,
>>>
>>> Regards,
>>>
>>> Cédric
>>>
>>> Le 16/03/2023 à 21:28, Marton Balint a écrit :
>>>>
>>>>
>>>>  On Thu, 16 Mar 2023, Cédric Le Barz wrote:
>>>>
>>>>>  Hi,
>>>>>
>>>>>  By "invalid", I mean that the written nb_index_entries value does 
>>>>> not
>>>>>  match with the real number of entries in the table. The number of
>>>>>  entries in the table is lower than the specified one. This is a 
>>>>> bug in
>>>>>  commercial MXFTk software (at least version V 2.8.0.0.1). It 
>>>>> exists a
>>>>>  lot a MXF files with this problem.
>>>>
>>>>  Please share a sample. Or better yet, open a ticket for this issue 
>>>> and
>>>>  attach a sample there for future reference.
>>>>
>>>>  Thanks,
>>>>  Marton
>>>>
>>>>>
>>>>>  Best regards,
>>>>>
>>>>>  Cédric
>>>>>
>>>>>  -----Message d'origine-----
>>>>>  De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de 
>>>>> Marton
>>>>>  Balint
>>>>>  Envoyé : mercredi 8 mars 2023 23:06
>>>>>  À : FFmpeg development discussions and patches 
>>>>> <ffmpeg-devel@ffmpeg.org>
>>>>>  Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid
>>>>>  nb_index_entries value is read - SPONSORED BY INA (Institut 
>>>>> National de
>>>>>  l'Audiovisuel)
>>>>>
>>>>>
>>>>>
>>>>>  On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>>>>>
>>>>>>
>>>>>>  Fix issue when invalid nb_index_entries value is read : in case of
>>>>>>  false nb_index_entries value, ffmpeg exit. This patch fix this 
>>>>>> problem.
>>>>>
>>>>>  What do you mean invalid? Is the value wrong, or is the file 
>>>>> truncated in
>>>>>  the middle of the index segment? From the patch it looks like the 
>>>>> latter.
>>>>>
>>>>>  Is there a single unluckily truncated file that you want to fix 
>>>>> with this
>>>>>  patch, or multiple files can be affected by this fix because e.g. 
>>>>> they
>>>>>  are written by the same broken muxer?
>>>>>
>>>>>  Overall I am not sure if we want this applied, the user can also 
>>>>> opt to
>>>>>  avoid parsing all partitions with -seekable 0 and read / remux 
>>>>> the file
>>>>>  sequentially ignoring any index, so if somebody wants to rescue 
>>>>> the data,
>>>>>  it can be done as is.
>>>>>
>>>>>  Regards,
>>>>>  Marton
>>>>>
>>>>>>
>>>>>>
>>>>>>  Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>>>>>>  ---
>>>>>>   ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>>>>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>>>>>
>>>>>>  diff --git a/ffmpeg/libavformat/mxfdec.c 
>>>>>> b/ffmpeg/libavformat/mxfdec.c
>>>>>>  index 4530617..ffc8987 100644
>>>>>>  --- a/ffmpeg/libavformat/mxfdec.c
>>>>>>  +++ b/ffmpeg/libavformat/mxfdec.c
>>>>>>  @@ -1221,8 +1221,18 @@ static int
>>>>>>  mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment 
>>>>>> *seg
>>>>>>       }
>>>>>>       for (i = 0; i < segment->nb_index_entries; i++) {
>>>>>>  -        if(avio_feof(pb))
>>>>>>  -            return AVERROR_INVALIDDATA;
>>>>>>  +
>>>>>>  +        if(avio_feof(pb)) {
>>>>>>  +            if (i == 0) {
>>>>>>  +                return AVERROR_INVALIDDATA;
>>>>>>  +            } else {
>>>>>>  +                /* To be more robust to invalid 
>>>>>> nb_index_entries value,
>>>>>>  +                   fix the index entry number according to read 
>>>>>> entries
>>>>>>  */
>>>>>>  +                segment->nb_index_entries = i;
>>>>>>  +                return 0;
>>>>>>  +            }
>>>>>>  +        }
>>>>>>  +
>>>>>>           segment->temporal_offset_entries[i] = avio_r8(pb);
>>>>>>           avio_r8(pb); /*
>>>>>>  KeyFrameOffset */
>>>>>>          segment->flag_entries[i] = avio_r8(pb);
>>>>>>  --
>>>>>>  2.34.1
>>>>>>
>>>>>>  _______________________________________________
>>>>>>  ffmpeg-devel mailing list
>>>>>>  ffmpeg-devel@ffmpeg.org
>>>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>>
>>>>>>  To unsubscribe, visit link above, or email
>>>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>>
>>>>>>
>>>>>  _______________________________________________
>>>>>  ffmpeg-devel mailing list
>>>>>  ffmpeg-devel@ffmpeg.org
>>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>>  To unsubscribe, visit link above, or email
>>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>
>>>>>  _______________________________________________
>>>>>  ffmpeg-devel mailing list
>>>>>  ffmpeg-devel@ffmpeg.org
>>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>>  To unsubscribe, visit link above, or email
>>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>  _______________________________________________
>>>>  ffmpeg-devel mailing list
>>>>  ffmpeg-devel@ffmpeg.org
>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>  To unsubscribe, visit link above, or email
>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>
>>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marton Balint March 26, 2023, 9:06 p.m. UTC | #9
On Fri, 24 Mar 2023, Cédric Le Barz wrote:

>
> Hi Marton,
>
> The previous link was not OK, sorry. The good link that will make you 
> possible to download the sample is the following : 
> https://estendirectapi.ektacom.com/download/ffmpeg/Sample.mxf

Ok, so I checked this, and the problem is that the muxer dumps some 
garbarge after the intended end of file (after the random index 
pack). The garbage is most likely some part of the MXF file already 
written, and our parser fails to parse it because of the 
truncation.

Overall I think it is better if we fully skip all data after a random 
index pack, because, if it exists, it has to be the last KLV item after a 
footer partition.

I will send a patch for that shortly.

Regards,
Marton


>
> Regards,
>
> Cédric
>
>
> Le 24/03/2023 à 10:13, Cédric Le Barz a écrit :
>>  Hi Marton,
>>
>>  A sample can be downloaded from here :
>>  https://estendirectapi.ektacom.com/download/ffmpeg/
>>
>>  Regards,
>>
>>  Cédric
>> 
>>
>>  Le 20/03/2023 à 21:03, Marton Balint a écrit :
>>> 
>>>
>>>  On Mon, 20 Mar 2023, Cédric Le Barz wrote:
>>>
>>>>  We have several samples but these are big files: about 7 GB. Is it OK to
>>>>  share such a file size ?
>>>
>>>  I kind of hoped you have access to the broken muxer and can remux a
>>>  small file which can be made public.
>>>
>>>  If not, then simply upload it somewhere so I can take a look. If the
>>>  sample can't be made public, just share it with me privately.
>>>
>>>  Thanks,
>>>  Marton
>>> 
>>>>
>>>>  Thanks for you answer,
>>>>
>>>>  Regards,
>>>>
>>>>  Cédric
>>>>
>>>>  Le 16/03/2023 à 21:28, Marton Balint a écrit :
>>>>> 
>>>>>
>>>>>   On Thu, 16 Mar 2023, Cédric Le Barz wrote:
>>>>>
>>>>>>   Hi,
>>>>>>
>>>>>>   By "invalid", I mean that the written nb_index_entries value does not
>>>>>>   match with the real number of entries in the table. The number of
>>>>>>   entries in the table is lower than the specified one. This is a bug
>>>>>>  in
>>>>>>   commercial MXFTk software (at least version V 2.8.0.0.1). It exists a
>>>>>>   lot a MXF files with this problem.
>>>>>
>>>>>   Please share a sample. Or better yet, open a ticket for this issue and
>>>>>   attach a sample there for future reference.
>>>>>
>>>>>   Thanks,
>>>>>   Marton
>>>>> 
>>>>>>
>>>>>>   Best regards,
>>>>>>
>>>>>>   Cédric
>>>>>>
>>>>>>   -----Message d'origine-----
>>>>>>   De : ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> De la part de
>>>>>>  Marton
>>>>>>   Balint
>>>>>>   Envoyé : mercredi 8 mars 2023 23:06
>>>>>>   À : FFmpeg development discussions and patches
>>>>>>  <ffmpeg-devel@ffmpeg.org>
>>>>>>   Objet : Re: [FFmpeg-devel] [PATCH] Fix issue when invalid
>>>>>>   nb_index_entries value is read - SPONSORED BY INA (Institut National
>>>>>>  de
>>>>>>   l'Audiovisuel)
>>>>>> 
>>>>>> 
>>>>>>
>>>>>>   On Wed, 8 Mar 2023, Cédric Le Barz wrote:
>>>>>> 
>>>>>>>
>>>>>>>   Fix issue when invalid nb_index_entries value is read : in case of
>>>>>>>   false nb_index_entries value, ffmpeg exit. This patch fix this
>>>>>>>  problem.
>>>>>>
>>>>>>   What do you mean invalid? Is the value wrong, or is the file
>>>>>>  truncated in
>>>>>>   the middle of the index segment? From the patch it looks like the
>>>>>>  latter.
>>>>>>
>>>>>>   Is there a single unluckily truncated file that you want to fix with
>>>>>>  this
>>>>>>   patch, or multiple files can be affected by this fix because e.g.
>>>>>>  they
>>>>>>   are written by the same broken muxer?
>>>>>>
>>>>>>   Overall I am not sure if we want this applied, the user can also opt
>>>>>>  to
>>>>>>   avoid parsing all partitions with -seekable 0 and read / remux the
>>>>>>  file
>>>>>>   sequentially ignoring any index, so if somebody wants to rescue the
>>>>>>  data,
>>>>>>   it can be done as is.
>>>>>>
>>>>>>   Regards,
>>>>>>   Marton
>>>>>> 
>>>>>>> 
>>>>>>>
>>>>>>>   Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
>>>>>>>   ---
>>>>>>>    ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
>>>>>>>    1 file changed, 12 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>>   diff --git a/ffmpeg/libavformat/mxfdec.c
>>>>>>>  b/ffmpeg/libavformat/mxfdec.c
>>>>>>>   index 4530617..ffc8987 100644
>>>>>>>   --- a/ffmpeg/libavformat/mxfdec.c
>>>>>>>   +++ b/ffmpeg/libavformat/mxfdec.c
>>>>>>>   @@ -1221,8 +1221,18 @@ static int
>>>>>>>   mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment
>>>>>>>  *seg
>>>>>>>        }
>>>>>>>        for (i = 0; i < segment->nb_index_entries; i++) {
>>>>>>>   -        if(avio_feof(pb))
>>>>>>>   -            return AVERROR_INVALIDDATA;
>>>>>>>   +
>>>>>>>   +        if(avio_feof(pb)) {
>>>>>>>   +            if (i == 0) {
>>>>>>>   +                return AVERROR_INVALIDDATA;
>>>>>>>   +            } else {
>>>>>>>   +                /* To be more robust to invalid nb_index_entries
>>>>>>>  value,
>>>>>>>   +                   fix the index entry number according to read
>>>>>>>  entries
>>>>>>>   */
>>>>>>>   +                segment->nb_index_entries = i;
>>>>>>>   +                return 0;
>>>>>>>   +            }
>>>>>>>   +        }
>>>>>>>   +
>>>>>>>            segment->temporal_offset_entries[i] = avio_r8(pb);
>>>>>>>            avio_r8(pb); /*
>>>>>>>   KeyFrameOffset */
>>>>>>>           segment->flag_entries[i] = avio_r8(pb);
>>>>>>>   --
>>>>>>>   2.34.1
>>>>>>>
>>>>>>>   _______________________________________________
>>>>>>>   ffmpeg-devel mailing list
>>>>>>>   ffmpeg-devel@ffmpeg.org
>>>>>>>   https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>>>
>>>>>>>   To unsubscribe, visit link above, or email
>>>>>>>   ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>>> 
>>>>>>>
>>>>>>   _______________________________________________
>>>>>>   ffmpeg-devel mailing list
>>>>>>   ffmpeg-devel@ffmpeg.org
>>>>>>   https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>>
>>>>>>   To unsubscribe, visit link above, or email
>>>>>>   ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>>
>>>>>>   _______________________________________________
>>>>>>   ffmpeg-devel mailing list
>>>>>>   ffmpeg-devel@ffmpeg.org
>>>>>>   https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>>
>>>>>>   To unsubscribe, visit link above, or email
>>>>>>   ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>>   _______________________________________________
>>>>>   ffmpeg-devel mailing list
>>>>>   ffmpeg-devel@ffmpeg.org
>>>>>   https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>>
>>>>>   To unsubscribe, visit link above, or email
>>>>>   ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>>  _______________________________________________
>>>>  ffmpeg-devel mailing list
>>>>  ffmpeg-devel@ffmpeg.org
>>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>  To unsubscribe, visit link above, or email
>>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>>> 
>>>>
>>>  _______________________________________________
>>>  ffmpeg-devel mailing list
>>>  ffmpeg-devel@ffmpeg.org
>>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>  To unsubscribe, visit link above, or email
>>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
diff mbox series

Patch

diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c
index 4530617..ffc8987 100644
--- a/ffmpeg/libavformat/mxfdec.c
+++ b/ffmpeg/libavformat/mxfdec.c
@@ -1221,8 +1221,18 @@  static int mxf_read_index_entry_array(AVIOContext 
*pb, MXFIndexTableSegment *seg
      }
       for (i = 0; i < segment->nb_index_entries; i++) {
-        if(avio_feof(pb))
-            return AVERROR_INVALIDDATA;
+
+        if(avio_feof(pb)) {
+            if (i == 0) {
+                return AVERROR_INVALIDDATA;
+            } else {
+                /* To be more robust to invalid nb_index_entries value,
+                   fix the index entry number according to read entries */
+                segment->nb_index_entries = i;
+                return 0;
+            }
+        }
+
          segment->temporal_offset_entries[i] = avio_r8(pb);
          avio_r8(pb);                                        /* 
KeyFrameOffset */