[FFmpeg-devel] [Read EXIF metadata 1/3] Refactor TIFF tag related functions to share the code.

Thilo Borgmann thilo.borgmann at mail.de
Sun Aug 11 18:52:49 CEST 2013


Am 11.08.13 14:19, schrieb Michael Niedermayer:
> On Sat, Aug 10, 2013 at 10:42:06PM +0200, Thilo Borgmann wrote:
>> Am 10.08.13 20:51, schrieb Michael Niedermayer:
>>> On Sat, Aug 10, 2013 at 01:27:38PM +0200, Thilo Borgmann wrote:
>>>> 1/3 rev 5
>>>>
>>>> -Thilo
>>> [...]
>>>
>>>> +int ff_tread_tag(AVCodecContext *avctx, GetByteContext *gb, int le,
>>>> +                 unsigned *tag, unsigned *type, unsigned *count, int *next)
>>>> +{
>>>> +    int ifd_tag;
>>>> +    int valid_type;
>>>> +
>>>> +    *tag    = ff_tget_short(gb, le);
>>>> +    *type   = ff_tget_short(gb, le);
>>>> +    *count  = ff_tget_long (gb, le);
>>>> +
>>>
>>>> +    ifd_tag    = ff_tis_ifd(*tag);
>>>> +    valid_type = ifd_tag || (*type != 0 && *type < FF_ARRAY_ELEMS(type_sizes));
>>>> +
>>>> +    // check for valid type
>>>> +    if (!valid_type) {
>>>> +        av_log(avctx, AV_LOG_DEBUG, "Unknown tiff tag type (%u) encountered\n",
>>>> +               *type);
>>>> +        return AVERROR_INVALIDDATA;
>>>> +    }
>>>
>>> unknown tags shouldnt be invalid
>>> also arent they already handled in the switch/case as "default"
>>> as is they get turned into a return 0 in the calling function and
>>> then likely failure of parsng of subsequent tags
>>
>> its about the type that must be valid in tiff.c because there are array access
>> with [type] beyond the call of ff_tread_tag.
>> For exif it is handled better in rev 6.
> 
> The tiff spec says
> "Warning: It is possible that other TIFF field types will be added in the future.
>  Readers should skip over fields containing an unexpected field type."

Now it does.

-Thilo



More information about the ffmpeg-devel mailing list