mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Properly check the lengths of Unix-socket pathnames.
If something is too long to fit in a sun_addr, we should spot that well in advance and not try.
This commit is contained in:
parent
a146ab2e7a
commit
bec33b2311
@ -134,7 +134,7 @@ agent_pending_query *agent_query(
|
|||||||
agent_pending_query *conn;
|
agent_pending_query *conn;
|
||||||
|
|
||||||
name = getenv("SSH_AUTH_SOCK");
|
name = getenv("SSH_AUTH_SOCK");
|
||||||
if (!name)
|
if (!name || strlen(name) >= sizeof(addr.sun_path))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
@ -146,7 +146,7 @@ agent_pending_query *agent_query(
|
|||||||
cloexec(sock);
|
cloexec(sock);
|
||||||
|
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strncpy(addr.sun_path, name, sizeof(addr.sun_path));
|
strcpy(addr.sun_path, name);
|
||||||
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||||
close(sock);
|
close(sock);
|
||||||
goto failure;
|
goto failure;
|
||||||
|
@ -1620,7 +1620,8 @@ SockAddr unix_sock_addr(const char *path)
|
|||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
ret->error = "snprintf failed";
|
ret->error = "snprintf failed";
|
||||||
else if (n >= sizeof ret->hostname)
|
else if (n >= sizeof ret->hostname ||
|
||||||
|
n >= sizeof(((struct sockaddr_un *)0)->sun_path))
|
||||||
ret->error = "socket pathname too long";
|
ret->error = "socket pathname too long";
|
||||||
|
|
||||||
#ifndef NO_IPV6
|
#ifndef NO_IPV6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user