Commit 6c356634 authored by André Goddard Rosa's avatar André Goddard Rosa Committed by Linus Torvalds

vsprintf: pre-calculate final string length for later use

Signed-off-by: default avatarAndré Goddard Rosa <andre.goddard@gmail.com>
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0f4f81dc
...@@ -1496,13 +1496,14 @@ do { \ ...@@ -1496,13 +1496,14 @@ do { \
case FORMAT_TYPE_STR: { case FORMAT_TYPE_STR: {
const char *save_str = va_arg(args, char *); const char *save_str = va_arg(args, char *);
size_t len; size_t len;
if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE
|| (unsigned long)save_str < PAGE_SIZE) || (unsigned long)save_str < PAGE_SIZE)
save_str = "(null)"; save_str = "(null)";
len = strlen(save_str); len = strlen(save_str) + 1;
if (str + len + 1 < end) if (str + len < end)
memcpy(str, save_str, len + 1); memcpy(str, save_str, len);
str += len + 1; str += len;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment