From 6eba304d136dd11f874953bacbe71cc134cdd2bb Mon Sep 17 00:00:00 2001 From: XieHan Date: Thu, 15 Apr 2021 15:36:16 +0800 Subject: [PATCH] fix unix domain socket path --- src/algorithm/DNSRoutine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithm/DNSRoutine.cc b/src/algorithm/DNSRoutine.cc index f5eb698c..40a45184 100644 --- a/src/algorithm/DNSRoutine.cc +++ b/src/algorithm/DNSRoutine.cc @@ -58,7 +58,7 @@ void DNSRoutine::run_local_path(const std::string& path, DNSOutput *out) { struct sockaddr_un *sun = NULL; - if (path.size() <= sizeof sun->sun_path) + if (path.size() + 1 <= sizeof sun->sun_path) { size_t size = sizeof (struct addrinfo) + sizeof (struct sockaddr_un); @@ -72,7 +72,7 @@ void DNSRoutine::run_local_path(const std::string& path, DNSOutput *out) out->addrinfo_->ai_family = AF_UNIX; out->addrinfo_->ai_socktype = SOCK_STREAM; out->addrinfo_->ai_addr = (struct sockaddr *)sun; - size = offsetof(struct sockaddr_un, sun_path) + path.size(); + size = offsetof(struct sockaddr_un, sun_path) + path.size() + 1; out->addrinfo_->ai_addrlen = size; out->error_ = 0; return;