diff options
author | Darwin Rambo <drambo@broadcom.com> | 2013-12-20 03:14:19 +0400 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-01-25 01:59:07 +0400 |
commit | 686f60f519a3b06dfc4571cfb0dd832467179479 (patch) | |
tree | 933c390c4edeaad27392a1396bccca8c0359a7d9 /lib | |
parent | de351d6be6868270db21ed8a0f89d3ef703bc18e (diff) | |
download | u-boot-686f60f519a3b06dfc4571cfb0dd832467179479.tar.xz |
lib: fix return codes when CONFIG_SYS_VSNPRINTF is enabled
When CONFIG_SYS_VSNPRINTF is enabled, it protects print operations
such as sprintf, snprintf, vsnprintf, etc., from buffer overflows.
But vsnprintf_internal includes the terminating NULL character in
the calculation of number of characters written. This affects sprintf
and snprintf return values. Fix this issue by setting pointer 'str'
back to the location of the '\0'.
Signed-off-by: Darwin Rambo <drambo@broadcom.com>
Reviewed-by: Steve Rae <srae@broadcom.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 82e5c13653..60874dae3e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -750,6 +750,7 @@ repeat: ADDCH(str, '\0'); if (str > end) end[-1] = '\0'; + --str; } #else *str = '\0'; |