1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-01-27 00:18:12 +03:00

agent: replace strncpy() with memcpy() (#1785)

This commit is contained in:
Lars Nordin
2026-01-15 12:37:59 +01:00
committed by GitHub
parent bd1d00a4b3
commit 179dbafb51

View File

@@ -502,10 +502,9 @@ agent_connect_unix(LIBSSH2_AGENT *agent)
}
s_un.sun_family = AF_UNIX;
/* !checksrc! disable BANNEDFUNC 1 */ /* FIXME */
strncpy(s_un.sun_path, path, sizeof(s_un.sun_path));
s_un.sun_path[sizeof(s_un.sun_path)-1] = 0; /* make sure there's a trailing
zero */
memcpy(s_un.sun_path, path, plen);
s_un.sun_path[plen] = '\0';
if(connect(agent->fd, (struct sockaddr*)(&s_un), sizeof(s_un)) != 0) {
close(agent->fd);
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,