[Bf-committers] fix to #2117

Joilnen Batista Leite vma_bad_list at yahoo.com
Tue Jan 25 02:34:35 CET 2005


humm !
i think that BLI_strncpy not copy more than maxncpy,
so it is more secure than strcpy 

Joilnen 

--- Alexander Ewering <blender at instinctive.de> wrote:

> 
> On Mon, 24 Jan 2005, Joilnen Batista Leite wrote:
> 
> > well,
> > here is BLI_strncpy code:
> >
> > char *BLI_strncpy(char *dst, char *src, int
> maxncpy) {
> >        int srclen= strlen(src);
> >        int cpylen=
> > (srclen>(maxncpy-1))?(maxncpy-1):srclen;
> >
> >        memcpy(dst, src, cpylen);
> >        dst[cpylen]= '\0';
> >
> >        return dst;
> > }
> > seems to return a terminated string for me.
> 
> That's very interesting.
> 
> I thought that BLI_strncpy was just a wrapper to the
> libc strncpy,
> which definitely does not null-terminate the string
> if it doesn't
> fit.
> 
> 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!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail


More information about the Bf-committers mailing list