aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-05-25 02:17:12 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2003-05-25 02:17:12 -0700
commitfaad0c2773e516753859cccac99171610220b9c3 (patch)
tree70763dcaec5573ba69870cbcbeac2db299d46fa4 /lib
parentdc2f9764e8784817355504b5a78bed08578e2d46 (diff)
downloadhistory-faad0c2773e516753859cccac99171610220b9c3.tar.gz
Do a strlcat() to go with the strlcpy().
Diffstat (limited to 'lib')
-rw-r--r--lib/string.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c
index b19212bc5d0073..112389ed554a6c 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -169,6 +169,33 @@ char * strncat(char *dest, const char *src, size_t count)
}
#endif
+#ifndef __HAVE_ARCH_STRLCAT
+/**
+ * strlcat - Append a length-limited, %NUL-terminated string to another
+ * @dest: The string to be appended to
+ * @src: The string to append to it
+ * @count: The size of the destination buffer.
+ */
+size_t strlcat(char *dest, const char *src, size_t count)
+{
+ size_t dsize = strlen(dest);
+ size_t len = strlen(src);
+ size_t res = dsize + len;
+
+ /* This would be a bug */
+ BUG_ON(dsize >= count);
+
+ dest += dsize;
+ count -= dsize;
+ if (len >= count)
+ len = count-1;
+ memcpy(dest, src, len);
+ dest[len] = 0;
+ return res;
+}
+EXPORT_SYMBOL(strlcat);
+#endif
+
#ifndef __HAVE_ARCH_STRCMP
/**
* strcmp - Compare two strings