Skip to content

Commit f271df9

Browse files
Vasily Gorbikhcahca
authored andcommitted
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>
1 parent fe20164 commit f271df9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

arch/s390/boot/string.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ int strncmp(const char *cs, const char *ct, size_t count)
2929
return 0;
3030
}
3131

32+
ssize_t sized_strscpy(char *dst, const char *src, size_t count)
33+
{
34+
size_t len;
35+
36+
if (count == 0)
37+
return -E2BIG;
38+
len = strnlen(src, count - 1);
39+
memcpy(dst, src, len);
40+
dst[len] = '\0';
41+
return src[len] ? -E2BIG : len;
42+
}
43+
3244
void *memset64(uint64_t *s, uint64_t v, size_t count)
3345
{
3446
uint64_t *xs = s;

0 commit comments

Comments
 (0)