diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-12 09:51:51 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-12 09:51:51 -0500 |
commit | 92ff05696506d423111fc7c0ff1e571f64af4615 (patch) | |
tree | e5c7edc9c920c54718ea8a40b651badedc8b29e6 | |
parent | eaad2886ee1c2fff25f473e4ab933e53ef959beb (diff) | |
download | horizon-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.cc | 4 |
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; } |