aboutsummaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorAndrew Jones <ajones@ventanamicro.com>2022-07-27 16:17:47 +0200
committerAnup Patel <anup@brainfault.org>2022-07-30 11:02:07 +0530
commit88b790f1291618274f94b6d5110ed09e20148bb2 (patch)
tree1ed3f87beb8c5131222acdcae8117a545a6b37ff /lib/utils
parent4e21ccacd1cccec697df0651a0bd212edef8be4f (diff)
downloadopensbi-88b790f1291618274f94b6d5110ed09e20148bb2.zip
opensbi-88b790f1291618274f94b6d5110ed09e20148bb2.tar.gz
opensbi-88b790f1291618274f94b6d5110ed09e20148bb2.tar.bz2
lib: sbi: Fix sbi_snprintf
printc would happily write to 'out' even when 'out_len' was zero, potentially overflowing buffers. Rework printc to not do that and also ensure the null byte is written at the last position when necessary, as stated in the snprintf man page. Also, panic if sprintf or snprintf are called with NULL output strings (except the special case of snprintf having a NULL output string and a zero output size, allowing it to be used to get the number of characters that would have been written). Finally, rename a goto label which clashed with 'out'. Fixes: 9e8ff05cb61f ("Initial commit.") Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/utils')
0 files changed, 0 insertions, 0 deletions