trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrushf...@apache.org
Subject [trafficserver] 02/02: Fix coverity issues 1379739
Date Tue, 29 Aug 2017 16:22:50 GMT
This is an automated email from the ASF dual-hosted git repository.

jrushford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 103ef3872a32aa7779a7bd8046682177c425861d
Author: jrushf1239k <John_Rushford@cable.comcast.com>
AuthorDate: Tue Aug 22 16:05:58 2017 +0000

    Fix coverity issues 1379739
---
 iocore/utils/Machine.cc | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/iocore/utils/Machine.cc b/iocore/utils/Machine.cc
index c2c24fd..82e71cb 100644
--- a/iocore/utils/Machine.cc
+++ b/iocore/utils/Machine.cc
@@ -293,21 +293,19 @@ Machine::insert_id(char *id)
 {
   char lower_case_name[TS_MAX_HOST_NAME_LEN + 1] = {0};
   char *value                                    = nullptr;
-  size_t len                                     = strlen(id);
 
-  value = static_cast<char *>(ats_malloc(len + 1));
   make_to_lower_case(id, lower_case_name, sizeof(lower_case_name));
-  strncpy(value, lower_case_name, strlen(lower_case_name));
+  value = ats_strndup(lower_case_name, strlen(lower_case_name));
   ink_hash_table_insert(machine_id_strings, lower_case_name, value);
 }
 
 void
 Machine::insert_id(IpAddr *ipaddr)
 {
-  int length         = INET6_ADDRSTRLEN + 1;
-  char *string_value = static_cast<char *>(ats_calloc(length, 1));
+  int length = INET6_ADDRSTRLEN + 1;
 
   if (ipaddr != nullptr) {
+    char *string_value = static_cast<char *>(ats_calloc(length, 1));
     ipaddr->toString(string_value, length);
     ink_hash_table_insert(machine_id_strings, string_value, string_value);
     ink_hash_table_insert(machine_id_ipaddrs, string_value, ipaddr);

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message