Skip to content

Commit

Permalink
Fix bunch of minor coverity issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Oct 23, 2024
1 parent 7db1f23 commit 064c77a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/pgp-key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ pgp_key_t::validate_sig(pgp_signature_info_t & sinfo,
if (!subpkt->critical() || (subpkt->type() != pgp::pkt::sigsub::Type::NotationData)) {
continue;
}
auto notation = dynamic_cast<pgp::pkt::sigsub::NotationData &>(*subpkt);
auto &notation = dynamic_cast<pgp::pkt::sigsub::NotationData &>(*subpkt);
RNP_LOG("unknown critical notation: %s", notation.name().c_str());
sinfo.valid = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sig_subpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,11 @@ bool
EmbeddedSignature::parse_data(const uint8_t *data, size_t size)
{
pgp_packet_body_t pkt(data, size);
pgp_signature_t sig{};
pgp_signature_t sig;
if (sig.parse(pkt)) {
return false;
}
signature_ = std::unique_ptr<pgp_signature_t>(new pgp_signature_t(sig));
signature_ = std::unique_ptr<pgp_signature_t>(new pgp_signature_t(std::move(sig)));
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/sig_subpacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ class RevocationKey : public Raw {

public:
RevocationKey(bool hashed = true, bool critical = false)
: Raw(Type::RevocationKey, hashed, critical){};
: Raw(Type::RevocationKey, hashed, critical), rev_class_(0),
alg_(PGP_PKA_NOTHING), fp_{} {};

uint8_t
rev_class() const noexcept
Expand Down Expand Up @@ -866,7 +867,7 @@ class IssuerFingerprint : public Raw {

public:
IssuerFingerprint(bool hashed = true, bool critical = false)
: Raw(Type::IssuerFingerprint, hashed, critical), version_(0)
: Raw(Type::IssuerFingerprint, hashed, critical), version_(0), fp_{}
{
}

Expand Down
3 changes: 3 additions & 0 deletions src/librepgp/stream-sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ pgp_signature_t::set_preferred(const std::vector<uint8_t> &data, sigsub::Type ty

auto sub = sigsub::Raw::create(type);
auto pref = dynamic_cast<sigsub::Preferred *>(sub.get());
if (!pref) {
return;

Check warning on line 436 in src/librepgp/stream-sig.cpp

View check run for this annotation

Codecov / codecov/patch

src/librepgp/stream-sig.cpp#L436

Added line #L436 was not covered by tests
}
pref->set_algs(data);
add_subpkt(std::move(sub));
}
Expand Down
4 changes: 2 additions & 2 deletions src/librepgp/stream-sig.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ typedef struct pgp_signature_t {
/* common v3 and v4 fields */
pgp_pubkey_alg_t palg;
pgp_hash_alg_t halg;
std::array<uint8_t, 2> lbits;
std::array<uint8_t, 2> lbits{};
std::vector<uint8_t> hashed_data;
std::vector<uint8_t> material_buf; /* raw signature material */

/* v3 - only fields */
uint32_t creation_time;
pgp_key_id_t signer;
pgp_key_id_t signer{};

/* common v4, v5 and v6 fields */
pgp::pkt::sigsub::List subpkts;
Expand Down

0 comments on commit 064c77a

Please sign in to comment.