diff options
Diffstat (limited to 'lib/string.c')
-rw-r--r-- | lib/string.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/string.c b/lib/string.c index 461fb620f85f..cd7a10c19210 100644 --- a/lib/string.c +++ b/lib/string.c | |||
@@ -173,8 +173,9 @@ EXPORT_SYMBOL(strlcpy); | |||
173 | * doesn't unnecessarily force the tail of the destination buffer to be | 173 | * doesn't unnecessarily force the tail of the destination buffer to be |
174 | * zeroed. If zeroing is desired please use strscpy_pad(). | 174 | * zeroed. If zeroing is desired please use strscpy_pad(). |
175 | * | 175 | * |
176 | * Return: The number of characters copied (not including the trailing | 176 | * Returns: |
177 | * %NUL) or -E2BIG if the destination buffer wasn't big enough. | 177 | * * The number of characters copied (not including the trailing %NUL) |
178 | * * -E2BIG if count is 0 or @src was truncated. | ||
178 | */ | 179 | */ |
179 | ssize_t strscpy(char *dest, const char *src, size_t count) | 180 | ssize_t strscpy(char *dest, const char *src, size_t count) |
180 | { | 181 | { |
@@ -182,7 +183,7 @@ ssize_t strscpy(char *dest, const char *src, size_t count) | |||
182 | size_t max = count; | 183 | size_t max = count; |
183 | long res = 0; | 184 | long res = 0; |
184 | 185 | ||
185 | if (count == 0) | 186 | if (count == 0 || WARN_ON_ONCE(count > INT_MAX)) |
186 | return -E2BIG; | 187 | return -E2BIG; |
187 | 188 | ||
188 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | 189 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
@@ -253,8 +254,9 @@ EXPORT_SYMBOL(strscpy); | |||
253 | * For full explanation of why you may want to consider using the | 254 | * For full explanation of why you may want to consider using the |
254 | * 'strscpy' functions please see the function docstring for strscpy(). | 255 | * 'strscpy' functions please see the function docstring for strscpy(). |
255 | * | 256 | * |
256 | * Return: The number of characters copied (not including the trailing | 257 | * Returns: |
257 | * %NUL) or -E2BIG if the destination buffer wasn't big enough. | 258 | * * The number of characters copied (not including the trailing %NUL) |
259 | * * -E2BIG if count is 0 or @src was truncated. | ||
258 | */ | 260 | */ |
259 | ssize_t strscpy_pad(char *dest, const char *src, size_t count) | 261 | ssize_t strscpy_pad(char *dest, const char *src, size_t count) |
260 | { | 262 | { |