summaryrefslogtreecommitdiffstats
path: root/lib/string.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-26 13:29:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-26 13:29:42 -0400
commitcbafe18c71028d5e0ee1626b4776fea5d5824a78 (patch)
tree2bb7db7db4ed8df2801f7c16553c69fb27379f7f /lib/string.c
parentf41def397161053eb0d3ed6861ef65985efbf293 (diff)
parenta22fea94992a2bc5328005e62f368413ede49c14 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: - almost all of the rest of -mm - various other subsystems Subsystems affected by this patch series: memcg, misc, core-kernel, lib, checkpatch, reiserfs, fat, fork, cpumask, kexec, uaccess, kconfig, kgdb, bug, ipc, lzo, kasan, madvise, cleanups, pagemap * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (77 commits) arch/sparc/include/asm/pgtable_64.h: fix build mm: treewide: clarify pgtable_page_{ctor,dtor}() naming ntfs: remove (un)?likely() from IS_ERR() conditions IB/hfi1: remove unlikely() from IS_ERR*() condition xfs: remove unlikely() from WARN_ON() condition wimax/i2400m: remove unlikely() from WARN*() condition fs: remove unlikely() from WARN_ON() condition xen/events: remove unlikely() from WARN() condition checkpatch: check for nested (un)?likely() calls hexagon: drop empty and unused free_initrd_mem mm: factor out common parts between MADV_COLD and MADV_PAGEOUT mm: introduce MADV_PAGEOUT mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM mm: introduce MADV_COLD mm: untag user pointers in mmap/munmap/mremap/brk vfio/type1: untag user pointers in vaddr_get_pfn tee/shm: untag user pointers in tee_shm_register media/v4l2-core: untag user pointers in videobuf_dma_contig_user_get drm/radeon: untag user pointers in radeon_gem_userptr_ioctl drm/amdgpu: untag user pointers ...
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c12
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 */
179ssize_t strscpy(char *dest, const char *src, size_t count) 180ssize_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 */
259ssize_t strscpy_pad(char *dest, const char *src, size_t count) 261ssize_t strscpy_pad(char *dest, const char *src, size_t count)
260{ 262{