summaryrefslogtreecommitdiff
path: root/lib/charset.c
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>2023-07-14 13:24:51 +0200
committerTom Rini <trini@konsulko.com>2023-08-08 17:05:43 -0400
commit7c00b80d48cbb28e5f6dfc232c344526e28f7176 (patch)
tree25c497c3509934e0c691ac0384f82deee75dc87e /lib/charset.c
parent615828721abfe8c73b5103d4436402ecbf9b9897 (diff)
downloadu-boot-7c00b80d48cbb28e5f6dfc232c344526e28f7176.tar.gz
u-boot-7c00b80d48cbb28e5f6dfc232c344526e28f7176.tar.bz2
u-boot-7c00b80d48cbb28e5f6dfc232c344526e28f7176.zip
lib/charset: fix u16_strlcat() return value
strlcat returns min(strlen(dest), count)+strlen(src). Make u16_strlcat's behaviour the same for consistency. Fixes: eca08ce94ceb ("lib/charset: add u16_strlcat() function") Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Diffstat (limited to 'lib/charset.c')
-rw-r--r--lib/charset.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/charset.c b/lib/charset.c
index b1842755eb..5e4c4f948a 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -444,14 +444,14 @@ u16 *u16_strdup(const void *src)
size_t u16_strlcat(u16 *dest, const u16 *src, size_t count)
{
- size_t destlen = u16_strlen(dest);
+ size_t destlen = u16_strnlen(dest, count);
size_t srclen = u16_strlen(src);
- size_t ret = destlen + srclen + 1;
+ size_t ret = destlen + srclen;
if (destlen >= count)
return ret;
- if (ret > count)
- srclen -= ret - count;
+ if (ret >= count)
+ srclen -= (ret - count + 1);
memcpy(&dest[destlen], src, 2 * srclen);
dest[destlen + srclen] = 0x0000;