s390/boot: Add sized_strscpy() to enable strscpy() usage

Add a simple sized_strscpy() implementation to allow the use of strscpy()
in the decompressor.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
Vasily Gorbik 2025-04-11 01:45:47 +02:00 committed by Heiko Carstens
parent fe20164177
commit f271df9d41
1 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,18 @@ int strncmp(const char *cs, const char *ct, size_t count)
return 0;
}
ssize_t sized_strscpy(char *dst, const char *src, size_t count)
{
size_t len;
if (count == 0)
return -E2BIG;
len = strnlen(src, count - 1);
memcpy(dst, src, len);
dst[len] = '\0';
return src[len] ? -E2BIG : len;
}
void *memset64(uint64_t *s, uint64_t v, size_t count)
{
uint64_t *xs = s;