From 151f36a406cd10bc819e022bdd92a9897538aef8 Mon Sep 17 00:00:00 2001 From: Kisoo Han Date: Wed, 24 Apr 2024 09:57:25 +0900 Subject: [PATCH] [CBRD-25319] fix FQDN stytle hostname error in use_user_hosts --- src/connection/host_lookup.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/connection/host_lookup.c b/src/connection/host_lookup.c index 6ef7291341e..bd6322ce7b8 100644 --- a/src/connection/host_lookup.c +++ b/src/connection/host_lookup.c @@ -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"; @@ -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; } @@ -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; } @@ -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; }