[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCHv3 24/25] nolibc: Clear a -Wstringop-overflow warning for strncpy
The strncpy needs a signed integer for 3rd parameter, but the SIZE_MAX is unsigned integer. We will get following error: /lib/nolibc/string.c:155:9: warning: ‘strncpy’: specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] return strncpy(dst, src, SIZE_MAX); ^ Using SSIZE_MAX to replace SIZE_MAX to fix this warning. Signed-off-by: Wei Chen <wei.chen@xxxxxxx> --- lib/nolibc/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nolibc/string.c b/lib/nolibc/string.c index 6f853ba..fa450c9 100644 --- a/lib/nolibc/string.c +++ b/lib/nolibc/string.c @@ -152,7 +152,7 @@ char *strncpy(char *dst, const char *src, size_t len) char *strcpy(char *dst, const char *src) { - return strncpy(dst, src, SIZE_MAX); + return strncpy(dst, src, SSIZE_MAX); } int strncmp(const char *str1, const char *str2, size_t len) -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |