aboutsummaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-02-05 16:16:38 -0500
committerTom Rini <trini@konsulko.com>2022-02-05 16:16:38 -0500
commitb5c5b9a0bee56030f9f05ece52334b5207b72673 (patch)
tree7d4f13a4800ffdf132344be5ee10510fac33766d /lib/vsprintf.c
parent3aaabfe9ff4bbcd11096513b1b28d1fb0a40800f (diff)
parent6bbe12f61c4f7208b428cc038170dc286c872a91 (diff)
Merge tag 'efi-2022-04-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2022-04-rc2-2 UEFI * add unit test for RISCV_EFI_BOOT_PROTOCOL * disable UEFI for Colibri VF610 * add handle for UART * fix printing of Unicode strings * simplify enumeration of block devices
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 69b2f6a1ad..fe06aa2d71 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -285,15 +285,25 @@ static __maybe_unused char *string16(char *buf, char *end, u16 *s,
if (!(flags & LEFT))
for (; len < field_width; --field_width)
ADDCH(buf, ' ');
- for (i = 0; i < len && buf + utf16_utf8_strnlen(str, 1) <= end; ++i) {
+ if (buf < end)
+ *buf = 0;
+ for (i = 0; i < len; ++i) {
+ int slen = utf16_utf8_strnlen(str, 1);
s32 s = utf16_get(&str);
if (s < 0)
s = '?';
- utf8_put(s, &buf);
+ if (buf + slen < end) {
+ utf8_put(s, &buf);
+ if (buf < end)
+ *buf = 0;
+ } else {
+ buf += slen;
+ }
}
for (; len < field_width; --field_width)
ADDCH(buf, ' ');
+
return buf;
}