[MPlayer-dev-eng] [PATCH] -identify DVD titles

Oded Shimon ods15 at ods15.dyndns.org
Wed Sep 21 13:16:03 CEST 2005


On Wed, Sep 21, 2005 at 12:57:14PM +0200, Aurelien Jacobs wrote:
> On Tue, 20 Sep 2005 23:57:04 -0400
> Rich Felker <dalias at aerifal.cx> wrote:
> 
> > On Tue, Sep 20, 2005 at 06:31:57PM -0500, Joey Parrish wrote:
> > > On Tue, Sep 20, 2005 at 05:45:19PM -0400, kiriuja wrote:
> > > > Updated patch.
> > > > 
> > > > - Added doxygen comments per Guillaume's suggestions.
> > > > - Fixed framerate application in dvdtimetomsec.
> > > > 
> > > > I did not change the way disk ID is output, since the only real
> > > > alternative is to allocate another buffer and put sprintf in a for
> > > > loop, which is not any better than the current way IMHO.
> > > 
> > > I believe I have a better solution.
> > > 
> > > > +      unsigned char discid [16]; ///< disk ID, a 128 bit MD5 sum
> > >  [ ... ]
> > > > +      if (DVDDiscID(dvd, discid) >= 0)
> > > > +        mp_msg(MSGT_GLOBAL, MSGL_INFO,
> > > > "ID_DVD_DISC_ID=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%
> > > > 02X%02X%02X%02X\n", +          discid[0], discid[1], discid[2],
> > > > discid[3], discid[4], discid[5], discid[6], discid[7], +         
> > > > discid[8], discid[9], discid[10], discid[11], discid[12],
> > > > discid[13], discid[14], discid[15]); +    }
> > > 
> > > Try this:
> > > 
> > >   #include "bswap.h"
> > >   [ ... ]
> > >   uint32_t discid[4]; ///< disk ID, a 128 bit MD5 sum
> > >   [ ... ]
> > >   if (DVDDiscID(dvd, (unsigned char *)discid))
> > >     mp_msg(MSGT_GLOBAL, MSGL_INFO,
> > >     "ID_DVD_DISC_ID=%08x%08x%08x%08x\n",
> > >       be2me_32(discid[0]), be2me_32(discid[1]), be2me_32(discid[2]),
> > >       be2me_32(discid[3]));
> > > 
> > > I may have gotten the byteswapping wrong, so try le2me_32 as well.
> > > Cola me if I screwed up something else.
> > 
> > Try this:
> > 
> > char buf[17];
> > for(i=0;i<16;i++) sprintf(buf+2*i, "%02X", discid[i]);
> > mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_DISC_ID=%s\n", buf);
> > 
> > Simple, readable, no possibility of endian problems or portability
> > issues.
> 
> But a nice buffer overflow ;-)
> This should probably be:
>   char buf[33];

Whats the buffer for to begin with, just mp_msg directly...

- ods15




More information about the MPlayer-dev-eng mailing list