Skip to content

Commit

Permalink
Fix CID 1540730, 1540707, 1540701: Uninitialized variables (UNINIT)
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 authored and antonsviridenko committed Mar 28, 2024
1 parent 232716e commit f464275
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/lib/key-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,24 @@ KeySearch::create(const std::string &name, const std::string &value)
return nullptr;
}
return create(pgp_fingerprint_t(binval));
case Type::KeyID:
case Type::KeyID: {
if (binval.size() != PGP_KEY_ID_SIZE) {
RNP_LOG("Invalid keyid: %s", value.c_str());
return nullptr;
}
pgp_key_id_t keyid;
pgp_key_id_t keyid{};
memcpy(keyid.data(), binval.data(), keyid.size());
return create(keyid);
case Type::Grip:
}
case Type::Grip: {
if (binval.size() != PGP_KEY_GRIP_SIZE) {
RNP_LOG("Invalid grip: %s", value.c_str());
return nullptr;
}
pgp_key_grip_t grip;
pgp_key_grip_t grip{};
memcpy(grip.data(), binval.data(), grip.size());
return create(grip);
}
default:
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librekey/key_store_g10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ KeyStore::load_g10(pgp_source_t &src, const KeyProvider *key_provider)
/* copy public key fields if any */
pgp_key_t key;
if (key_provider) {
pgp_key_grip_t grip;
pgp_key_grip_t grip{};
if (!seckey.material.get_grip(grip)) {
return false;
}
Expand Down

0 comments on commit f464275

Please sign in to comment.