linux/include
Chris Metcalf a648dc92ac string: provide strscpy()
commit 30035e4575 upstream.

The strscpy() API is intended to be used instead of strlcpy(),
and instead of most uses of strncpy().

- Unlike strlcpy(), it doesn't read from memory beyond (src + size).

- Unlike strlcpy() or strncpy(), the API provides an easy way to check
  for destination buffer overflow: an -E2BIG error return value.

- The provided implementation is robust in the face of the source
  buffer being asynchronously changed during the copy, unlike the
  current implementation of strlcpy().

- Unlike strncpy(), the destination buffer will be NUL-terminated
  if the string in the source buffer is too long.

- Also unlike strncpy(), the destination buffer will not be updated
  beyond the NUL termination, avoiding strncpy's behavior of zeroing
  the entire tail end of the destination buffer.  (A memset() after
  the strscpy() can be used if this behavior is desired.)

- The implementation should be reasonably performant on all
  platforms since it uses the asm/word-at-a-time.h API rather than
  simple byte copy.  Kernel-to-kernel string copy is not considered
  to be performance critical in any case.

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-10-21 08:46:12 +01:00
..
acpi ACPICA: Tables: Enable default 64-bit FADT addresses favor 2015-07-15 10:01:11 +01:00
asm-generic Make asm/word-at-a-time.h available on all architectures 2018-10-21 08:46:11 +01:00
clocksource drivers: clocksource: add support for ARM architected timer event stream 2013-09-26 09:48:00 +01:00
crypto crypto: hash - prevent using keyed hashes without setting key 2018-06-16 22:21:52 +01:00
drm drm: Allow determining if current task is output poll worker 2018-06-16 22:22:18 +01:00
dt-bindings pinctrl: dra: dt-bindings: Fix output pull up/down 2014-11-27 11:22:05 +00:00
keys KEYS: Separate the kernel signature checking keyring from module signing 2013-09-25 17:17:01 +01:00
kvm arm/arm64: KVM: Require in-kernel vgic for the arch timers 2015-05-20 13:25:52 +01:00
linux string: provide strscpy() 2018-10-21 08:46:12 +01:00
math-emu math-emu: fix floating-point to integer overflow detection 2014-01-07 18:36:24 -06:00
media media: vb2: fix VBI/poll regression 2014-10-09 12:23:49 -07:00
memory ddr: add LPDDR2 data from JESD209-2 2012-05-02 00:04:06 -07:00
misc [media] altera-stapl: it is time to move out from staging 2011-09-23 15:00:57 -03:00
net soreuseport: initialise timewait reuseport field 2018-10-21 08:45:18 +01:00
pcmcia pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate 2013-03-15 12:26:03 -07:00
ras edac: add support for error type "Info" 2013-02-21 14:16:27 -03:00
rdma RDMA/ucma: Introduce safer rdma_addr_size() variants 2018-10-21 08:45:39 +01:00
rxrpc atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
scsi scsi: libsas: remove the numbering for each event enum 2018-06-16 22:21:30 +01:00
sound ALSA: control: Hardening for potential Spectre v1 2018-10-21 08:45:42 +01:00
target target/iscsi: Fix iSCSI task reassignment handling 2018-02-13 18:42:18 +00:00
trace tracing/x86/xen: Remove zero data size trace events trace_xen_mmu_flush_tlb{_all} 2018-10-21 08:46:06 +01:00
uapi tty: handle the case where we cannot restore a line discipline 2018-10-21 08:45:38 +01:00
video Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2014-06-12 11:32:30 -07:00
xen xen: Add xen_arch_suspend() 2018-06-16 22:22:30 +01:00
Kbuild UAPI: remove empty Kbuild files 2013-04-30 17:04:09 -07:00