diff options
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index b19212bc5d00..112389ed554a 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 |
