[pubcookie-dev] CVS update: willey; webiso/pubcookie/src strlcpy.c,2.12,2.13

willey at washington.edu willey at washington.edu
Mon Nov 20 18:46:33 PST 2006


Update of /usr/local/cvsroot/webiso/pubcookie/src
 In directory webiso-cvs.cac.washington.edu:/var/tmp/cvs-serv15001
 
 Modified Files:
 	strlcpy.c 
 Log Message:
 fixed null termination in strlcpy when len-1 == length of input string
 



Index: webiso/pubcookie/src/strlcpy.c
diff -u webiso/pubcookie/src/strlcpy.c:2.12 webiso/pubcookie/src/strlcpy.c:2.13
--- webiso/pubcookie/src/strlcpy.c:2.12	Wed Feb 22 16:46:33 2006
+++ webiso/pubcookie/src/strlcpy.c	Mon Nov 20 18:46:31 2006
@@ -18,7 +18,7 @@
 /** @file strlcpy.c
  * strlcpy()
  *
- * $Id: strlcpy.c,v 2.12 2006/02/23 00:46:33 willey Exp $
+ * $Id: strlcpy.c,v 2.13 2006/11/21 02:46:31 willey Exp $
  */
 
 
@@ -55,14 +55,14 @@
     size_t n;
 
     /* Avoid problems if size_t is unsigned */
-    if (len == 0)
+    if (len <= 0)
         return strlen (src);
 
     for (n = 0; n < len - 1; n++) {
         if ((dst[n] = src[n]) == '\0')
             break;
     }
-    if (src[n] != '\0') {
+    if (n >= len-1) {
         /* ran out of space */
         dst[n] = '\0';
         while (src[n])



end of message


More information about the pubcookie-dev mailing list