You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
file/SOURCES/file-5.42-cve-strlcpy.patch

21 lines
498 B

diff --git a/src/funcs.c b/src/funcs.c
index 9bd054f..a5363e7 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -54,9 +54,12 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.118 2020/12/08 21:26:00 christos Exp $")
protected char *
file_copystr(char *buf, size_t blen, size_t width, const char *str)
{
- if (++width > blen)
- width = blen;
- strlcpy(buf, str, width);
+ if (blen == 0)
+ return buf;
+ if (width >= blen)
+ width = blen - 1;
+ memcpy(buf, str, width);
+ buf[width] = '\0';
return buf;
}