Skip to content

Commit 2747c99

Browse files
authored
Fix Coverity UNINIT issues (#12842)
* Fix uninitialized DiagsConfigState in reconfigure_diags Value-initialize DiagsConfigState to ensure the outputs array members are initialized to false before use. This fixes Coverity CID 1497238 (UNINIT). * Fix uninitialized ParsedValue in ParsedConfigCache::parse Explicitly value-initialize ParsedValue to ensure the variant member is properly initialized. This fixes Coverity CID 1644237 (UNINIT). * Fix uninitialized TLSClientHelloSummary in test_ja4 Value-initialize TLSClientHelloSummary to ensure all members are properly initialized before use. This fixes Coverity CID 1644228 (UNINIT). * Fix uninitialized IPRange in background_fetch and cache_fill plugins The condition for parsing Client-IP was inverted - it should load the IP range when the value is NOT a single '*' character. With the old logic, single-character non-'*' values would skip loading, leaving the IPRange uninitialized. This fixes Coverity CID 1533658 (UNINIT).
1 parent 1796051 commit 2747c99

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

plugins/background_fetch/configs.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ BgFetchConfig::readConfig(const char *config_file)
136136
if ("Client-IP"_tv == cfg_name) {
137137
swoc::IPRange r;
138138
// '*' is special - match any address. Signalled by empty range.
139-
if (cfg_value.size() != 1 || cfg_value.front() == '*') {
139+
if (cfg_value.size() != 1 || cfg_value.front() != '*') {
140140
if (!r.load(cfg_value)) { // assume if it loads, it's not empty.
141141
TSError("[%s] invalid IP address range %.*s, skipping config value", PLUGIN_NAME, int(cfg_value.size()),
142142
cfg_value.data());

plugins/experimental/cache_fill/configs.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ BgFetchConfig::readConfig(const char *config_file)
146146
if ("Client-IP"_tv == cfg_name) {
147147
swoc::IPRange r;
148148
// '*' is special - match any address. Signalled by empty range.
149-
if (cfg_value.size() != 1 || cfg_value.front() == '*') {
149+
if (cfg_value.size() != 1 || cfg_value.front() != '*') {
150150
if (!r.load(cfg_value)) { // assume if it loads, it's not empty.
151151
TSError("[%s] invalid IP address range %.*s, skipping config value", PLUGIN_NAME, int(cfg_value.size()),
152152
cfg_value.data());

plugins/experimental/ja4_fingerprint/test_ja4.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static std::string inc(std::string_view sv);
3737

3838
TEST_CASE("JA4")
3939
{
40-
JA4::TLSClientHelloSummary TLS_summary;
40+
JA4::TLSClientHelloSummary TLS_summary{};
4141

4242
SECTION("Given the protocol is TCP, "
4343
"when we create a JA4 fingerprint, "

src/proxy/http/HttpConfig.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ ParsedConfigCache::lookup_impl(TSOverridableConfigKey key, std::string_view valu
745745
ParsedConfigCache::ParsedValue
746746
ParsedConfigCache::parse(TSOverridableConfigKey key, std::string_view value)
747747
{
748-
ParsedValue result;
748+
ParsedValue result{};
749749

750750
// Store the string value - the parsed structures may reference this.
751751
result.conf_value_storage = std::string(value);

src/proxy/shared/DiagsConfig.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void
4242
DiagsConfig::reconfigure_diags()
4343
{
4444
int i;
45-
DiagsConfigState c;
45+
DiagsConfigState c{};
4646
bool found, all_found;
4747

4848
static struct {

0 commit comments

Comments
 (0)