Skip to content

Commit

Permalink
[CBRD-25319] fix FQDN stytle hostname error in use_user_hosts (#5144)
Browse files Browse the repository at this point in the history
fix FQDN resolving error in use_user_hosts
  • Loading branch information
kisoo-han authored and YeunjunLee committed Jun 4, 2024
1 parent e2d92df commit 2420c75
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit 2420c75

Please sign in to comment.