Date: Fri, 11 Nov 2022 18:36:54 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 7cefb4bc4b1c - stable/13 - libfetch: Use memcpy in place of an odd strncpy. Message-ID: <202211111836.2ABIasWe004207@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7cefb4bc4b1cf8c5e61a2dde8c84249712290319 commit 7cefb4bc4b1cf8c5e61a2dde8c84249712290319 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-10-03 23:10:43 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-11-11 18:18:54 +0000 libfetch: Use memcpy in place of an odd strncpy. The length passed to strncpy is the length of the source string, not the destination buffer. This triggers a non-fatal warning in GCC 12. Hoewver, the code is also odd. It is really just a memcpy of the string without its nul terminator. For that use case, memcpy is clearer. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D36824 (cherry picked from commit 611cf392672cf7aa52a593412fb2537546a7d6a4) --- lib/libfetch/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 628ab69612f7..47545e5178c3 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -456,7 +456,7 @@ fetch_socks5_init(conn_t *conn, const char *host, int port, int verbose) goto fail; } *ptr++ = strlen(host); - strncpy(ptr, host, strlen(host)); + memcpy(ptr, host, strlen(host)); ptr = ptr + strlen(host); port = htons(port);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211111836.2ABIasWe004207>