[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCHv3 24/25] nolibc: Clear a -Wstringop-overflow warning for strncpy
Hello Wei Chen, Please find my comments inline. Thanks & Regards Sharan On 12/13/18 10:15 AM, Wei Chen wrote: 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); [1] show the posix standard function declaration strncpy using size_t[2] as the third parameter. The upstream code seems to be correct. I am not sure if we need this patch. ^ 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) [1] http://pubs.opengroup.org/onlinepubs/009696899/functions/strncpy.html [2] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |