chiark / gitweb /
Make run_directory.c stat the place it is going to try to run.
[elogind.git] / klibc / klibc / strlcpy.c
index eb384c9885d2a3710c007375376903f4b1732788..e6937445cd64e5a0a8da91e8cbfeb3924604ad8a 100644 (file)
@@ -13,13 +13,16 @@ size_t strlcpy(char *dst, const char *src, size_t size)
   char ch;
 
   while ( (ch = *p++) ) {
-    if ( bytes < size )
+    if ( bytes+1 < size )
       *q++ = ch;
 
     bytes++;
   }
 
-  *q = '\0';
+  /* If size == 0 there is no space for a final null... */
+  if ( size )
+    *q = '\0';
+
   return bytes;
 }