You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/08/12 20:04:05 UTC

[trafficserver] branch 9.0.x updated: ensure hostname_offset is initialized to '0' to indicate null hostname (#8239)

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 8a4d491  ensure hostname_offset is initialized to '0' to indicate null hostname (#8239)
8a4d491 is described below

commit 8a4d4916cd863e47e8496c41bd7ddb2945ffdfda
Author: Brian Olsen <bn...@gmail.com>
AuthorDate: Thu Aug 12 14:03:53 2021 -0600

    ensure hostname_offset is initialized to '0' to indicate null hostname (#8239)
    
    (cherry picked from commit 976bc758d57c1092dc3823ae7d7584d74d28f81d)
---
 iocore/hostdb/HostDB.cc           | 6 +++++-
 iocore/hostdb/I_HostDBProcessor.h | 8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 5101dc8..c9888a9 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -2328,7 +2328,11 @@ struct HostDBRegressionContinuation : public Continuation {
       // since this is a lookup done, data is either hostdbInfo or nullptr
       if (r) {
         rprintf(test, "hostdbinfo r=%x\n", r);
-        rprintf(test, "hostdbinfo hostname=%s\n", r->perm_hostname());
+        char const *hname = r->perm_hostname();
+        if (nullptr == hname) {
+          hname = "(null)";
+        }
+        rprintf(test, "hostdbinfo hostname=%s\n", hname);
         rprintf(test, "hostdbinfo rr %x\n", r->rr());
         // If RR, print all of the enclosed records
         if (r->rr()) {
diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h
index fbf068a..6924d5c 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -323,7 +323,7 @@ struct HostDBInfo : public RefCountObj {
 
   int iobuffer_index;
 
-  uint64_t key;
+  uint64_t key{0};
 
   // Application specific data. NOTE: We need an integral number of
   // these per block. This structure is 32 bytes. (at 200k hosts =
@@ -336,11 +336,11 @@ struct HostDBInfo : public RefCountObj {
     SRVInfo srv;
   } data;
 
-  unsigned int hostname_offset; // always maintain a permanent copy of the hostname for non-rev dns records.
+  unsigned int hostname_offset{0}; // always maintain a permanent copy of the hostname for non-rev dns records.
 
-  unsigned int ip_timestamp;
+  unsigned int ip_timestamp{0};
 
-  unsigned int ip_timeout_interval; // bounded between 1 and HOST_DB_MAX_TTL (0x1FFFFF, 24 days)
+  unsigned int ip_timeout_interval{0}; // bounded between 1 and HOST_DB_MAX_TTL (0x1FFFFF, 24 days)
 
   unsigned int is_srv : 1;
   unsigned int reverse_dns : 1;