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

Michael Niedermayer michaelni at gmx.at
Sun Aug 11 14:19:31 CEST 2013


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."

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130811/59e16786/attachment.asc>


More information about the ffmpeg-devel mailing list