Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept underscore as valid char in hostname strings #430

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Increase minimum gpgme version [#405](https://github.com/greenbone/gvm-libs/pull/405)
- Always NULL check ifaddrs->ifa_addr [#416](https://github.com/greenbone/gvm-libs/pull/416)
- Correct g_hash_table_remove arg [#419](https://github.com/greenbone/gvm-libs/pull/419)
- Accept underscore as valid char in hostname strings [#429](https://github.com/greenbone/gvm-libs/pull/429)

[20.8.1]: https://github.com/greenbone/gvm-libs/compare/v20.8.0...gvm-libs-20.08

Expand Down
2 changes: 1 addition & 1 deletion base/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ is_hostname (const char *str)

point = split;
while (*point)
if (g_regex_match_simple ("^(?!-)[a-z0-9-]{1,63}(?<!-)$", *point,
if (g_regex_match_simple ("^(?!-)[a-z0-9_-]{1,63}(?<!-)$", *point,
G_REGEX_CASELESS, 0)
== 0)
{
Expand Down
4 changes: 4 additions & 0 deletions base/hosts_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Ensure (hosts, gvm_get_host_type_returns_host_type_hostname)
{
assert_that (gvm_get_host_type ("www.greenbone.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("www.example_underscore.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("www.example-dash.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("greenbone.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("g"), is_equal_to (HOST_TYPE_NAME));
Expand Down