summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Allen <screwtape@froup.com>2022-04-07 21:36:15 +1000
committerTim Allen <screwtape@froup.com>2022-04-07 21:36:15 +1000
commit9cf8a3ccd6531c2cf2695b4598c6ceff75ed2dc9 (patch)
tree87f4ffc1bc30f113194a1b022d3dc360e8b8a3d4 /src
parent9e6b678cf709986e3ee83d1354da577f7f436c47 (diff)
Check for buffer overflow when constructing the socket path.
Diffstat (limited to 'src')
-rw-r--r--src/remote.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/remote.cc b/src/remote.cc
index 7a8f0d02..63a7fecf 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -614,7 +614,10 @@ static sockaddr_un session_addr(StringView session)
{
sockaddr_un addr;
addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, session_path(session).c_str());
+ String path = session_path(session);
+ if (path.length() + 1 > sizeof addr.sun_path)
+ throw runtime_error{format("socket path too long: '{}'", path)};
+ strcpy(addr.sun_path, path.c_str());
return addr;
}