kdelibs/kio/kio

Oswald Buddenhagen ossi at kde.org
Sat Dec 7 17:58:21 GMT 2002


On Sat, Dec 07, 2002 at 05:39:47PM +0100, Waldo Bastian wrote:
> CVS commit by waba: 
> 
> Proper string handling. Patch by Peter Hawkins <peter at hawkins.emu.id.au>
> 
> +  if (p != NULL)
> +  {
> +    strncpy( p, _name+1, l-1 );
> +    p[l-1] = 0;
> +  }
>  
as i see oodles of such constructs, i'm going to do two things:

- substitute all such uses of strncpy with strlcpy. of course i'll add a
  configure check and a substitute to kdefakes.

  http://www.openbsd.org/cgi-bin/man.cgi?query=strlcpy&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

  oh, maybe add strlcat, too? it's not really often used, though.

- add a new function to kdefakes (it's no fake, but it fits nicely :)

  char *mem2str (char *dst, const char *src, size_t len)
  {
    memcpy (dst, src, len);
    dst[len] = 0;
    return dst;
  }

  this construct is often used (be it by the strlcpy implementation :), 
  so i think it's worth it.

greetings
  
-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.




More information about the kde-core-devel mailing list