Skip to content

Commit 8befa94

Browse files
committed
json output: remove IP format checking in Config to allow domain names to be entered
Unnecessary IP address value validation step disallowed entering valid domain names/hostnames as a destination to send JSON records to despite the rest of the plugin code allowing it. Fixes github issue #91
1 parent 1a61a3b commit 8befa94

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

src/plugins/output/json/src/Config.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,6 @@ static const struct fds_xml_args args_params[] = {
257257
FDS_OPTS_END
258258
};
259259

260-
/**
261-
* \brief Check if a given string is a valid IPv4/IPv6 address
262-
* \param[in] ip_addr Address to check
263-
* \return True or false
264-
*/
265-
bool
266-
Config::check_ip(const std::string &ip_addr)
267-
{
268-
in_addr ipv4;
269-
in6_addr ipv6;
270-
271-
return (inet_pton(AF_INET, ip_addr.c_str(), &ipv4) == 1
272-
|| inet_pton(AF_INET6, ip_addr.c_str(), &ipv6) == 1);
273-
}
274-
275260
/**
276261
* \brief Check one of 2 expected options
277262
*
@@ -436,9 +421,9 @@ Config::parse_send(fds_xml_ctx_t *send)
436421
throw std::runtime_error("Name of a <send> output must be defined!");
437422
}
438423

439-
if (output.addr.empty() || !check_ip(output.addr)) {
424+
if (output.addr.empty()) {
440425
throw std::runtime_error("Value of the element <ip> of the output <send> '" + output.name
441-
+ "' is not a valid IPv4/IPv6 address");
426+
+ "' must be defined!");
442427
}
443428

444429
outputs.sends.push_back(output);

src/plugins/output/json/src/Config.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ struct cfg_syslog : cfg_output {
177177
/** Parsed configuration of an instance */
178178
class Config {
179179
private:
180-
bool check_ip(const std::string &ip_addr);
181180
bool check_or(const std::string &elem, const char *value, const std::string &val_true,
182181
const std::string &val_false);
183182
bool is_syslog_ascii(const std::string &str);

0 commit comments

Comments
 (0)