This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 9ca028f30d Fix remaining uninitialized variable and field Coverity
defects (#13004)
9ca028f30d is described below
commit 9ca028f30d32218f6592a4b54bfa441bec9613cc
Author: Bryan Call <[email protected]>
AuthorDate: Mon Mar 23 12:57:44 2026 -0700
Fix remaining uninitialized variable and field Coverity defects (#13004)
* Initialize previously uninitialized fields in HttpVCTableEntry,
HostStatRec, ChunkedHandler, and TLSSNISupport::ClientHello so core HTTP/TLS
paths start from deterministic state.
* Initialize local variables in cache_fill and txn_box to eliminate
undefined behavior flagged by Coverity.
* Remove HttpVCTable memset and rely on proper member initialization to
avoid non-portable initialization of pointer-to-member-function types.
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 +-
plugins/experimental/txn_box/plugin/src/Ex_Base.cc | 2 +-
src/proxy/http/HttpVCTable.cc | 6 +-----
7 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/include/iocore/net/TLSSNISupport.h
b/include/iocore/net/TLSSNISupport.h
index 346c2c1c0a..2ce9556f43 100644
--- a/include/iocore/net/TLSSNISupport.h
+++ b/include/iocore/net/TLSSNISupport.h
@@ -84,7 +84,7 @@ public:
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 7e81f11646..fdf2de2d3b 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 961c3f6cdf..f245a8452f 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 e1157e4075..2521f3cf43 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 c0cfd0d27d..c9d1b7b3ff 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 bf3ac5166f..b9bb01d76d 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<store_type>()[0];
auto &&[value, errata] = ctx._txn.override_fetch(*var);
if (errata.is_ok()) {
diff --git a/src/proxy/http/HttpVCTable.cc b/src/proxy/http/HttpVCTable.cc
index 01690daee0..056e833c6d 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()