lib: fix return codes when CONFIG_SYS_VSNPRINTF is enabled
Subsystems (2)
PATCH 1/1 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'.
--- lib/vsprintf.c | 1 + 1 file changed, 1 insertion(+)
lib/vsprintf.c +1 -0
@@ -750,6 +750,7 @@ repeat:ADDCH (str,'\0' );if (str > end) end[-1 ] ='\0' ; + --str; }#else *str ='\0' ;
Signature · 1 line
1.7.9.5
Quoted 9 lines · Darwin Rambo
When
CONFIG_SYS_VSNPRINTFis enabled, it protects print operations such as sprintf, snprintf, vsnprintf, etc., from buffer overflows. Butvsnprintf_internalincludes 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 <[email protected]>Reviewed-by Steve Rae <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140127/8bf9d960/attachment.pgp>