summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2004-06-15 11:14:45 +1000
committerDamien Miller <djm@mindrot.org>2004-06-15 11:14:45 +1000
commit07b6ff12c4fe59b46fba870c223ffffbb3501eec (patch)
treed32805d2b4d7ed95ea29465a9e7ed48d13ec3e01 /ssh.c
parent5e6f4db085d1278e0d5264e4ab000863a3d46d6e (diff)
- (djm) [ssh.c] Use separate var for address length
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ssh.c b/ssh.c
index 1c6ec8b6a..4badd2961 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1042,13 +1042,14 @@ ssh_control_listener(void)
1042{ 1042{
1043 struct sockaddr_un addr; 1043 struct sockaddr_un addr;
1044 mode_t old_umask; 1044 mode_t old_umask;
1045 1045 int addr_len;
1046
1046 if (options.control_path == NULL || options.control_master != 1) 1047 if (options.control_path == NULL || options.control_master != 1)
1047 return; 1048 return;
1048 1049
1049 memset(&addr, '\0', sizeof(addr)); 1050 memset(&addr, '\0', sizeof(addr));
1050 addr.sun_family = AF_UNIX; 1051 addr.sun_family = AF_UNIX;
1051 addr.sun_len = offsetof(struct sockaddr_un, sun_path) + 1052 addr_len = offsetof(struct sockaddr_un, sun_path) +
1052 strlen(options.control_path) + 1; 1053 strlen(options.control_path) + 1;
1053 1054
1054 if (strlcpy(addr.sun_path, options.control_path, 1055 if (strlcpy(addr.sun_path, options.control_path,
@@ -1059,7 +1060,7 @@ ssh_control_listener(void)
1059 fatal("%s socket(): %s\n", __func__, strerror(errno)); 1060 fatal("%s socket(): %s\n", __func__, strerror(errno));
1060 1061
1061 old_umask = umask(0177); 1062 old_umask = umask(0177);
1062 if (bind(control_fd, (struct sockaddr*)&addr, addr.sun_len) == -1) { 1063 if (bind(control_fd, (struct sockaddr*)&addr, addr_len) == -1) {
1063 control_fd = -1; 1064 control_fd = -1;
1064 if (errno == EINVAL) 1065 if (errno == EINVAL)
1065 fatal("ControlSocket %s already exists", 1066 fatal("ControlSocket %s already exists",
@@ -1229,13 +1230,13 @@ static void
1229control_client(const char *path) 1230control_client(const char *path)
1230{ 1231{
1231 struct sockaddr_un addr; 1232 struct sockaddr_un addr;
1232 int r, sock, exitval; 1233 int r, sock, exitval, addr_len;
1233 Buffer m; 1234 Buffer m;
1234 char *cp; 1235 char *cp;
1235 1236
1236 memset(&addr, '\0', sizeof(addr)); 1237 memset(&addr, '\0', sizeof(addr));
1237 addr.sun_family = AF_UNIX; 1238 addr.sun_family = AF_UNIX;
1238 addr.sun_len = offsetof(struct sockaddr_un, sun_path) + 1239 addr_len = offsetof(struct sockaddr_un, sun_path) +
1239 strlen(path) + 1; 1240 strlen(path) + 1;
1240 1241
1241 if (strlcpy(addr.sun_path, path, 1242 if (strlcpy(addr.sun_path, path,
@@ -1245,7 +1246,7 @@ control_client(const char *path)
1245 if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) 1246 if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
1246 fatal("%s socket(): %s", __func__, strerror(errno)); 1247 fatal("%s socket(): %s", __func__, strerror(errno));
1247 1248
1248 if (connect(sock, (struct sockaddr*)&addr, addr.sun_len) == -1) 1249 if (connect(sock, (struct sockaddr*)&addr, addr_len) == -1)
1249 fatal("Couldn't connect to %s: %s", path, strerror(errno)); 1250 fatal("Couldn't connect to %s: %s", path, strerror(errno));
1250 1251
1251 if ((cp = getenv("TERM")) == NULL) 1252 if ((cp = getenv("TERM")) == NULL)