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
This commit is contained in:
John Baldwin 2022-10-03 16:10:43 -07:00
parent 3736b2dd32
commit 611cf39267

View file

@ -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);