summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-12 09:51:51 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-12 09:51:51 -0500
commit92ff05696506d423111fc7c0ff1e571f64af4615 (patch)
treee5c7edc9c920c54718ea8a40b651badedc8b29e6
parenteaad2886ee1c2fff25f473e4ab933e53ef959beb (diff)
downloadhorizon-92ff05696506d423111fc7c0ff1e571f64af4615.tar.gz
horizon-92ff05696506d423111fc7c0ff1e571f64af4615.tar.bz2
horizon-92ff05696506d423111fc7c0ff1e571f64af4615.tar.xz
horizon-92ff05696506d423111fc7c0ff1e571f64af4615.zip
hscript: Fix dot logic in Hostname::execute
-rw-r--r--hscript/meta.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc
index 6bf4587..faec607 100644
--- a/hscript/meta.cc
+++ b/hscript/meta.cc
@@ -74,13 +74,13 @@ bool Hostname::execute(ScriptOptions opts) const {
* That's fine, because we have a limit of 64 chars per segment.
* Assuming a dot is present, just chop at the first dot. */
std::string::size_type dot = this->_value.find_first_of('.');
- if(dot == std::string::npos) {
+ if(dot == std::string::npos || dot >= 64) {
output_error("installfile:" + std::to_string(this->lineno()),
"hostname: nodename too long",
"Linux requires nodename to be <= 64 characters.");
return false;
}
- std::copy_n(this->_value.cbegin(), dot, actual.begin());
+ std::copy_n(this->_value.cbegin(), dot - 1, actual.begin());
} else {
actual = this->_value;
}