Signed-off-by: André Goddard Rosa andre.goddard@gmail.com Acked-by: Frederic Weisbecker fweisbec@gmail.com --- lib/vsprintf.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 002f462..403e835 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1445,13 +1445,15 @@ do { \ case FORMAT_TYPE_STR: { const char *save_str = va_arg(args, char *); size_t len; + if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE || (unsigned long)save_str < PAGE_SIZE) save_str = null_str; - len = strlen(save_str); - if (str + len + 1 < end) - memcpy(str, save_str, len + 1); - str += len + 1; + len = strlen(save_str) + 1; + if (str + len < end) + memcpy(str, save_str, len); + str += len; + break; }