From a269ca746a851ef16eec1117d2573b98901e9492 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Thu, 3 Oct 2024 16:54:08 -0400 Subject: [PATCH] Exit when agent encounters malformed url in configuration file --- src/mtconnect/configuration/agent_config.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mtconnect/configuration/agent_config.cpp b/src/mtconnect/configuration/agent_config.cpp index c87e5b85..14616809 100644 --- a/src/mtconnect/configuration/agent_config.cpp +++ b/src/mtconnect/configuration/agent_config.cpp @@ -911,7 +911,15 @@ namespace mtconnect::configuration { auto parsed = Url::parse(url); options[configuration::Protocol] = parsed.m_protocol; - options[configuration::Host] = parsed.getHost(); + + auto host = parsed.getHost(); + if (host.empty()) + { + LOG(fatal) << "Malformed URL in configuration file: '" << url << "', exiting"; + exit(1); + } + options[configuration::Host] = host; + if (parsed.m_port) options[configuration::Port] = parsed.getPort(); if (parsed.m_path != "/")