summaryrefslogtreecommitdiff
path: root/lib/842
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2016-01-16 03:58:34 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-16 22:17:26 +0300
commit34fc8b9076254513e00607134792a1b67483d2cf (patch)
treebb3c404923c35577a03b49a237cc8643040bf516 /lib/842
parent95508cfa10503bbe5adb78bd1b2b56a01ab3dd2d (diff)
downloadlinux-34fc8b9076254513e00607134792a1b67483d2cf.tar.xz
lib/vsprintf.c: eliminate potential race in string()
If the string corresponding to a %s specifier can change under us, we might end up copying a \0 byte to the output buffer. There might be callers who expect the output buffer to contain a genuine C string whose length is exactly the snprintf return value (assuming truncation hasn't happened or has been checked for). We can avoid this by only passing over the source string once, stopping the first time we meet a nul byte (or when we reach the given precision), and then letting widen_string() handle left/right space padding. As a small bonus, this code reuse also makes the generated code slightly smaller. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Joe Perches <joe@perches.com> Cc: Kees Cook <keescook@chromium.org> Cc: Maurizio Lombardi <mlombard@redhat.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/842')
0 files changed, 0 insertions, 0 deletions