From: Rocco Rutte Date: Sun, 11 Jun 2006 12:33:32 GMT Subject: Re: [PATCH] Implement safe_strncpy() as strlcpy() and use it more. [Take 2] Message-ID: <20060611123332.GA3832@robert.daprodeges.fqdn.th-h.de> In-Reply-To: <20060611120328.GC10430@bohr.gbar.dtu.dk> Hi, * Peter Eriksen [06-06-11 14:03:28 +0200] wrote: >-char *safe_strncpy(char *dest, const char *src, size_t n) >+size_t safe_strncpy(char *dest, const char *src, size_t size) > { >- strncpy(dest, src, n); >- dest[n - 1] = '\0'; >+ size_t ret = strlen(src); At least FreeBSD's strlen() requires a non-NULL argument, i.e. with src==NULL, this will segfault. If you can ensure that src!=NULL, then it's okay, but the safe_ prefix implies something different. bye, Rocco -- :wq!