Skip to content
Snippets Groups Projects
Unverified Commit 851e9c5d authored by Reynald Bourtembourg's avatar Reynald Bourtembourg Committed by GitHub
Browse files

Merge pull request #8 from bourtemb/fix-tangoHostWithDomainCrash

Fix potential crash in AttributeName::tangoHostWithDomain()
parents 4a11b720 be2aa138
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ...@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
## [0.11.1] - 2020-01-22
### Fixed
- Fix potential crash in AttributeName::tangoHostWithDomain() [#8](https://github.com/tango-controls-hdbpp/libhdbpp-timescale/pull/8)
## [0.11.0] - 2020-01-21 ## [0.11.0] - 2020-01-21
### Added ### Added
......
...@@ -94,7 +94,7 @@ const string &AttributeName::tangoHostWithDomain() ...@@ -94,7 +94,7 @@ const string &AttributeName::tangoHostWithDomain()
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
struct addrinfo *result, *rp; struct addrinfo *result;
const int status = getaddrinfo(server_name.c_str(), nullptr, &hints, &result); const int status = getaddrinfo(server_name.c_str(), nullptr, &hints, &result);
if (status != 0) if (status != 0)
...@@ -105,8 +105,20 @@ const string &AttributeName::tangoHostWithDomain() ...@@ -105,8 +105,20 @@ const string &AttributeName::tangoHostWithDomain()
return tangoHost(); return tangoHost();
} }
for (rp = result; rp != nullptr; rp = rp->ai_next) if (result == nullptr)
server_name_with_domain = string(rp->ai_canonname) + tango_host.substr(tango_host.find(':', 0)); {
spdlog::error("Error: Unable to add domain to tango host {}: getaddrinfo didn't return the canonical name (result == nullptr)", tango_host);
return tangoHost();
}
if (result->ai_canonname == nullptr)
{
spdlog::error("Error: Unable to add domain to tango host {}: getaddrinfo didn't return the canonical name (result->ai_canonname == nullptr)", tango_host);
freeaddrinfo(result);
return tangoHost();
}
server_name_with_domain = string(result->ai_canonname) + tango_host.substr(tango_host.find(':', 0));
freeaddrinfo(result); // all done with this structure freeaddrinfo(result); // all done with this structure
_tango_host_with_domain_cache = server_name_with_domain; _tango_host_with_domain_cache = server_name_with_domain;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment