[FFmpeg-devel] [PATCH] support for UTF-16 encoding in id3v2 tags
Reimar Döffinger
Reimar.Doeffinger
Sat Sep 12 18:47:34 CEST 2009
On Sat, Sep 12, 2009 at 06:12:37PM +0200, Anton Khirnov wrote:
> On Sat, Sep 12, 2009 at 02:46:54PM +0200, Reimar D?ffinger wrote:
> >
> > This should probably be done in a separate patch, but IMO the if(...) in
> > PUT_UTF8 should go and instead the while condition should check we have
> > at least space for 7+1 bytes in dst.
> > Also since dstlen == sizeof(dst) - 1 both this and the existing code are
> > off by 1 I think.
> >
> > > + *q = '\0';
> >
> > Again more an issue with the existing code, but I am allergic to that
> > '\0' clutter instead of a simple 0.
>
> i don't think it's necessary to check for 7 bytes - PUT_UTF8 will make
> max 2-byte sequences from single bytes and max 4 byte sequences from
> 20-bit characters that GET_UTF16 produces.
Seven is the documented maximum of PUT_UTF8, for anything else you are
making assumptions like e.g. there is no accidental sign expansion and
generally you rely on undocumented behaviour.
Given that it "saves" maximum 5 bytes that seems like a rather silly
"optimization" given it is security-relevant code.
I think I have no other comments beyond that.
More information about the ffmpeg-devel
mailing list