[Bf-committers] fix to #2117

Joilnen Batista Leite vma_bad_list at yahoo.com
Wed Jan 26 10:38:38 CET 2005


ok 
it is fixed using siizeof buffer exactly.
sure that thougth about sizeof buffer not the variable
char pointer name

Joilnen 


--- Douglas Toltzman <doug at oakstreetsoftware.com>
wrote:

> You are missing Alexander's point completely.
> 
> The safe use of BLI_strncpy would be something like
> this;
> 
> char buffer[80];
> BLI_strncpy(buffer,name,sizeof(buffer));
> 
> But the code in question used "strlen(name)+1" for
> the copy length where
> name could be longer than what will fit in the
> target buffer, and could
> cause a buffer overflow.  When used this way,
> strcpy(buffer,name) would
> perform EXACTLY the same function.
> 
> Some things are just so obvious, they are easy to
> overlook.
> 
> Douglas Toltzman
> Hubert, NC
> 
> On Mon, 24 Jan 2005, Joilnen Batista Leite wrote:
> 
> > humm !
> > i think that BLI_strncpy not copy more than
> maxncpy,
> > so it is more secure than strcpy 
> > 
> > Joilnen 
> -- snip --
> > > However, it still doesn't change the fact that
> the
> > > call
> > > 
> > > BLI_strncpy( self->name, name, strlen( name ) +
> 1 );
> > > 
> > > is fully equivalent to:
> > > 
> > > strcpy(self->name, name);
> > > 
> > > | alexander ewering              instinctive
> > > mediaworks
> > > | ae[@]instinctive[.]de  
> > > http://www[.]instinctive[.]de
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
>
http://projects.blender.org/mailman/listinfo/bf-committers
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Bf-committers mailing list