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

[CBRD-25319] 11.3 fix FQDN stytle hostname error in use_user_hosts #5145

Merged
merged 1 commit into from
Apr 25, 2024
Merged
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
15 changes: 8 additions & 7 deletions src/connection/host_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ load_hosts_file ()
char host_conf_file_full_path[PATH_MAX];
char *hosts_conf_dir;

char *token, temp_token[LINE_BUF_SIZE + 1];
char *token;
char *save_ptr_strtok;
/*delimiter */
const char *delim = " \t\n";
Expand Down Expand Up @@ -292,10 +292,9 @@ load_hosts_file ()
{
break;
}
strcpy (temp_token, token);
if (hostent_flag == INSERT_IPADDR)
{
if (is_valid_ip (temp_token) == false)
if (is_valid_ip (token) == false)
{
continue;
}
Expand All @@ -313,16 +312,16 @@ load_hosts_file ()
break;
}

str_len = strlen (temp_token);
str_len = strlen (token);
if (str_len > HOSTNAME_LEN - 1)
{
continue;
}
else if (is_valid_ip (temp_token) == true)
else if (is_valid_ip (token) == true)
{
continue;
}
else if (is_valid_hostname (temp_token, str_len) == false)
else if (is_valid_hostname (token, str_len) == false)
{
continue;
}
Expand Down Expand Up @@ -385,8 +384,10 @@ is_valid_ip (char *ip_addr)
char *token;
char *save_ptr_strtok;
const char *delim = " .\n";
char temp_str[LINE_BUF_SIZE + 1];

if ((token = strtok_r (ip_addr, delim, &save_ptr_strtok)) == NULL)
snprintf (temp_str, LINE_BUF_SIZE + 1, "%s", ip_addr);
if ((token = strtok_r (temp_str, delim, &save_ptr_strtok)) == NULL)
{
goto err_phase;
}
Expand Down
Loading