# HG changeset patch # User Rob Landley # Date 1195165113 21600 # Node ID 5f206fe8d9659d791212696ca9287826fb97ae46 # Parent 28d2042bcc13a248eba3fa5f2fb51a913f5c4cf5 Change strlcpy not to use strncpy. (Adds 24 bytes, but doesn't memset the unused portion of the buffer to 0, which can touch and allocate physical pages for a large virtual mapping.) diff -r 28d2042bcc13 -r 5f206fe8d965 lib/lib.c --- a/lib/lib.c Mon Nov 12 19:24:52 2007 -0600 +++ b/lib/lib.c Thu Nov 15 16:18:33 2007 -0600 @@ -18,8 +18,12 @@ // Like strncpy but always null terminated. void strlcpy(char *dest, char *src, size_t size) { - strncpy(dest,src,size); - dest[size-1] = 0; + int len = strlen(src); + if (size--) { + if (len > size) len=size; + memcpy(dest,src, len); + dest[len] = 0; + } } #endif