[MPlayer-cvslog] CVS: main/libmpdemux demux_ty.c,1.16,1.17

Rich Felker dalias at aerifal.cx
Fri Mar 10 00:19:18 CET 2006


On Thu, Mar 09, 2006 at 11:28:12PM +0100, Reimar Döffinger wrote:
> Hi,
> On Thu, Mar 09, 2006 at 05:16:49PM -0500, Rich Felker wrote:
> > On Wed, Mar 08, 2006 at 10:13:19PM +0100, Reimar Döffinger CVS wrote:
> > > -   char    name[ 80 ];
> > > +   char    name[ 100 ];
> > >     char    sizestr[ 80 ];
> > >     int     size;
> > >     int     count;
> > > @@ -201,8 +201,8 @@
> > >           error = 1;
> > >           break;
> > >        }
> > > -      strncpy( name, &header[ 0 ], 100 );
> > > -      strncpy( sizestr, &header[ 124 ], 12 );
> > > +      strlcpy( name, &header[ 0 ], 100 );
> > > +      strlcpy( sizestr, &header[ 124 ], 12 );
> > 
> > s/100/sizeof name/
> > etc.
> > Makes code more robust against changes and readable.
> 
> I though of that, but decided it is a bad idea. I assumed that 100 is
> the length of the data part in the header. Also it would be confusing to
> use sizeof here but not for sizestr. The "correct" solution would
> probably be a define. Feel free to improve the code as much as you want
> though ;-).

If the data part in the header is 100 bytes, does it always include
null termination, or not? If not, the name array needs to be 101 bytes
rather than 100.

Rich




More information about the MPlayer-cvslog mailing list