提交 686f60f5 编写于 作者: D Darwin Rambo 提交者: Tom Rini

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: NDarwin Rambo <drambo@broadcom.com>
Reviewed-by: NSteve Rae <srae@broadcom.com>
上级 de351d6b
......@@ -750,6 +750,7 @@ repeat:
ADDCH(str, '\0');
if (str > end)
end[-1] = '\0';
--str;
}
#else
*str = '\0';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册