diff options
author | Hiroki Tagato <tagattie@FreeBSD.org> | 2020-05-27 12:11:01 +0000 |
---|---|---|
committer | Hiroki Tagato <tagattie@FreeBSD.org> | 2020-05-27 12:11:01 +0000 |
commit | 1a0a41c91a7b078176d8e3ba75e5899e96277fae (patch) | |
tree | c7448c00dd7ed59cbf24b6930a2d4c85bf7d7227 /dns/powerdns-recursor/files/patch-hostnamemax | |
parent | Document powerdns-recursor vulnerabilities (diff) |
- Update to 4.3.1
- Mark broken on i386
- Updated hostnamemax patch
PR: 246655
Submitted by: Ralf van der Enden <tremere@cainites.net> (maintainer)
Approved by: ehaupt (mentor)
MFH: 2020Q2 (blanket, security fixes)
Security: f9c5a410-9b4e-11ea-ac3f-6805ca2fa271
Changelog: https://doc.powerdns.com/recursor/changelog/4.3.html#change-4.3.1
Notes
Notes:
svn path=/head/; revision=536690
Diffstat (limited to 'dns/powerdns-recursor/files/patch-hostnamemax')
-rw-r--r-- | dns/powerdns-recursor/files/patch-hostnamemax | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/dns/powerdns-recursor/files/patch-hostnamemax b/dns/powerdns-recursor/files/patch-hostnamemax new file mode 100644 index 000000000000..38beefb1026d --- /dev/null +++ b/dns/powerdns-recursor/files/patch-hostnamemax @@ -0,0 +1,90 @@ +diff --git misc.cc misc.cc +index f9248af42a..5cb4dbe812 100644 +--- misc.cc ++++ misc.cc +@@ -57,6 +57,7 @@ + #include <sys/types.h> + #include <pwd.h> + #include <grp.h> ++#include <limits.h> + #ifdef __FreeBSD__ + # include <pthread_np.h> + #endif +@@ -1563,3 +1564,39 @@ bool setPipeBufferSize(int fd, size_t size) + return false; + #endif /* F_SETPIPE_SZ */ + } ++ ++static size_t getMaxHostNameSize() ++{ ++#if defined(HOST_NAME_MAX) ++ return HOST_NAME_MAX; ++#endif ++ ++#if defined(_SC_HOST_NAME_MAX) ++ auto tmp = sysconf(_SC_HOST_NAME_MAX); ++ if (tmp != -1) { ++ return tmp; ++ } ++#endif ++ ++ /* _POSIX_HOST_NAME_MAX */ ++ return 255; ++} ++ ++std::string getCarbonHostName() ++{ ++ std::string hostname; ++ hostname.resize(getMaxHostNameSize() + 1, 0); ++ ++ if (gethostname(const_cast<char*>(hostname.c_str()), hostname.size()) != 0) { ++ throw std::runtime_error(stringerror()); ++ } ++ ++ auto pos = hostname.find("."); ++ if (pos != std::string::npos) { ++ hostname.resize(pos); ++ } ++ ++ boost::replace_all(hostname, ".", "_"); ++ ++ return hostname; ++} +diff --git misc.hh misc.hh +index 4bd9439a87..795e8ec855 100644 +--- misc.hh ++++ misc.hh +@@ -607,3 +607,5 @@ bool isSettingThreadCPUAffinitySupported(); + int mapThreadToCPUList(pthread_t tid, const std::set<int>& cpus); + + std::vector<ComboAddress> getResolvers(const std::string& resolvConfPath); ++ ++std::string getCarbonHostName(); +diff --git rec-carbon.cc rec-carbon.cc +index 4e0cedb00f..458a25d5ca 100644 +--- rec-carbon.cc ++++ rec-carbon.cc +@@ -32,17 +32,13 @@ try + if(namespace_name.empty()) { + namespace_name="pdns"; + } +- if(hostname.empty()) { +- char tmp[HOST_NAME_MAX+1]; +- memset(tmp, 0, sizeof(tmp)); +- if (gethostname(tmp, sizeof(tmp)) != 0) { +- throw std::runtime_error("The 'carbon-ourname' setting has not been set and we are unable to determine the system's hostname: " + stringerror()); ++ if (hostname.empty()) { ++ try { ++ hostname = getCarbonHostName(); ++ } ++ catch(const std::exception& e) { ++ throw std::runtime_error(std::string("The 'carbon-ourname' setting has not been set and we are unable to determine the system's hostname: ") + e.what()); + } +- char *p = strchr(tmp, '.'); +- if(p) *p=0; +- +- hostname=tmp; +- boost::replace_all(hostname, ".", "_"); + } + if(instance_name.empty()) { + instance_name="recursor"; |