From 92ff05696506d423111fc7c0ff1e571f64af4615 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 12 Oct 2019 09:51:51 -0500 Subject: hscript: Fix dot logic in Hostname::execute --- hscript/meta.cc | 4 ++-- 1 file 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; } -- cgit v1.2.3-70-g09d2