From 9b7c57f72cb21a7e5695947f7fef27674e2a2342 Mon Sep 17 00:00:00 2001 From: Bryan Call Date: Thu, 19 Mar 2026 15:06:28 -0700 Subject: [PATCH 1/2] Fix remaining uninitialized variable and field Coverity defects. Add in-class brace initialization for uninitialized members in HttpVCTableEntry, HostStatRec, ChunkedHandler, and TLSSNISupport ClientHello. Initialize local enum and Feature variables in cache_fill and txn_box plugins. CIDs: 1021690, 1508845, 1533658, 1534712, 1544456, 1645800. --- include/iocore/net/TLSSNISupport.h | 2 +- include/proxy/HostStatus.h | 18 +++++++-------- include/proxy/http/HttpTunnel.h | 2 +- include/proxy/http/HttpVCTable.h | 22 +++++++++---------- plugins/experimental/cache_fill/configs.cc | 2 +- .../txn_box/plugin/src/Ex_Base.cc | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/iocore/net/TLSSNISupport.h b/include/iocore/net/TLSSNISupport.h index 22f3d751a8b..8f3532bf935 100644 --- a/include/iocore/net/TLSSNISupport.h +++ b/include/iocore/net/TLSSNISupport.h @@ -84,7 +84,7 @@ class TLSSNISupport ClientHelloContainer _chc; #if HAVE_SSL_CTX_SET_CLIENT_HELLO_CB int *_ext_ids = nullptr; - size_t _ext_len; + size_t _ext_len{0}; #endif }; diff --git a/include/proxy/HostStatus.h b/include/proxy/HostStatus.h index 7e81f116461..fdf2de2d3bb 100644 --- a/include/proxy/HostStatus.h +++ b/include/proxy/HostStatus.h @@ -99,17 +99,17 @@ struct HostStatuses { // host status POD struct HostStatRec { - TSHostStatus status; - unsigned int reasons; + TSHostStatus status{TSHostStatus::TS_HOST_STATUS_INIT}; + unsigned int reasons{0}; // time the host was marked down for a given reason. - time_t active_marked_down; - time_t local_marked_down; - time_t manual_marked_down; - time_t self_detect_marked_down; + time_t active_marked_down{0}; + time_t local_marked_down{0}; + time_t manual_marked_down{0}; + time_t self_detect_marked_down{0}; // number of seconds that the host should be marked down for a given reason. - unsigned int active_down_time; - unsigned int local_down_time; - unsigned int manual_down_time; + unsigned int active_down_time{0}; + unsigned int local_down_time{0}; + unsigned int manual_down_time{0}; HostStatRec(); HostStatRec(std::string str); diff --git a/include/proxy/http/HttpTunnel.h b/include/proxy/http/HttpTunnel.h index 961c3f6cdfa..f245a8452f8 100644 --- a/include/proxy/http/HttpTunnel.h +++ b/include/proxy/http/HttpTunnel.h @@ -132,7 +132,7 @@ struct ChunkedHandler { //@{ /// The maximum chunk size. /// This is the preferred size as well, used whenever possible. - int64_t max_chunk_size; + int64_t max_chunk_size{DEFAULT_MAX_CHUNK_SIZE}; /// Caching members to avoid using printf on every chunk. /// It holds the header for a maximal sized chunk which will cover /// almost all output chunks. diff --git a/include/proxy/http/HttpVCTable.h b/include/proxy/http/HttpVCTable.h index e1157e4075d..2521f3cf439 100644 --- a/include/proxy/http/HttpVCTable.h +++ b/include/proxy/http/HttpVCTable.h @@ -41,17 +41,17 @@ enum class HttpVC_t { }; struct HttpVCTableEntry { - VConnection *vc; - MIOBuffer *read_buffer; - MIOBuffer *write_buffer; - VIO *read_vio; - VIO *write_vio; - HttpSMHandler vc_read_handler; - HttpSMHandler vc_write_handler; - HttpVC_t vc_type; - HttpSM *sm; - bool eos; - bool in_tunnel; + VConnection *vc{nullptr}; + MIOBuffer *read_buffer{nullptr}; + MIOBuffer *write_buffer{nullptr}; + VIO *read_vio{nullptr}; + VIO *write_vio{nullptr}; + HttpSMHandler vc_read_handler{}; + HttpSMHandler vc_write_handler{}; + HttpVC_t vc_type{HttpVC_t::UNKNOWN}; + HttpSM *sm{nullptr}; + bool eos{false}; + bool in_tunnel{false}; }; struct HttpVCTable { diff --git a/plugins/experimental/cache_fill/configs.cc b/plugins/experimental/cache_fill/configs.cc index c0cfd0d27d9..c9d1b7b3ff9 100644 --- a/plugins/experimental/cache_fill/configs.cc +++ b/plugins/experimental/cache_fill/configs.cc @@ -157,7 +157,7 @@ BgFetchConfig::readConfig(const char *config_file) swoc::bwprint(ts::bw_dbg, "adding background_fetch address range rule {} for {}: {}", exclude, cfg_name, cfg_value); Dbg(dbg_ctl, "%s", ts::bw_dbg.c_str()); } else if ("Content-Length"_tv == cfg_name) { - BgFetchRule::size_cmp_type::OP op; + BgFetchRule::size_cmp_type::OP op{BgFetchRule::size_cmp_type::LESS_THAN_OR_EQUAL}; if (cfg_value[0] == '<') { op = BgFetchRule::size_cmp_type::LESS_THAN_OR_EQUAL; } else if (cfg_value[0] == '>') { diff --git a/plugins/experimental/txn_box/plugin/src/Ex_Base.cc b/plugins/experimental/txn_box/plugin/src/Ex_Base.cc index bf3ac5166fa..b9bb01d76da 100644 --- a/plugins/experimental/txn_box/plugin/src/Ex_Base.cc +++ b/plugins/experimental/txn_box/plugin/src/Ex_Base.cc @@ -299,7 +299,7 @@ Ex_txn_conf::validate(Config &cfg, Spec &spec, const TextView &arg) Feature Ex_txn_conf::extract(Context &ctx, const Extractor::Spec &spec) { - Feature zret{}; + Feature zret{NIL_FEATURE}; auto var = spec._data.span.rebind()[0]; auto &&[value, errata] = ctx._txn.override_fetch(*var); if (errata.is_ok()) { From 3ce96784697ffb5fef608290fa84aa9abc31ff55 Mon Sep 17 00:00:00 2001 From: Bryan Call Date: Thu, 19 Mar 2026 18:54:34 -0700 Subject: [PATCH 2/2] Remove memset from HttpVCTable constructor. HttpVCTableEntry members now have in-class default initialization, making the memset redundant. Using memset on pointer-to-member-function types (HttpSMHandler) is also technically non-portable. Use a proper initializer list for the sm member instead. --- src/proxy/http/HttpVCTable.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/proxy/http/HttpVCTable.cc b/src/proxy/http/HttpVCTable.cc index 01690daee00..056e833c6de 100644 --- a/src/proxy/http/HttpVCTable.cc +++ b/src/proxy/http/HttpVCTable.cc @@ -30,11 +30,7 @@ class HttpSM; -HttpVCTable::HttpVCTable(HttpSM *mysm) -{ - memset(&vc_table, 0, sizeof(vc_table)); - sm = mysm; -} +HttpVCTable::HttpVCTable(HttpSM *mysm) : sm(mysm) {} HttpVCTableEntry * HttpVCTable::new_entry()