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

Thilo Borgmann thilo.borgmann at googlemail.com
Sat Aug 10 22:42:06 CEST 2013


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.

-Thilo


More information about the ffmpeg-devel mailing list