mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-10-29 22:26:22 +00:00
Fix some defects detected by Coverity Scan (#22)
* Clang Tidy fixes * Fix defects detected by Coverity Scan --------- Co-authored-by: cesaaargm <cesare.martinez@proton.me>
This commit is contained in:
parent
7367b56725
commit
5a6d19be70
@ -271,7 +271,7 @@ void osnma_msg_receiver::process_osnma_message(const std::shared_ptr<OSNMA_msg>&
|
||||
{
|
||||
d_flag_PK_renewal = false;
|
||||
uint32_t final_GST = d_helper->compute_gst(osnma_msg->WN_sf0, osnma_msg->TOW_sf0);
|
||||
double duration_hours = (final_GST - d_GST_PKR_PKREV_start) / 3600;
|
||||
double duration_hours = (final_GST - d_GST_PKR_PKREV_start) / 3600.0;
|
||||
LOG(INFO) << "Galileo OSNMA: Public Key Renewal :: Finished at GST=" << duration_hours << ", Duration=" << duration_hours << " h";
|
||||
std::cout << "Galileo OSNMA: Public Key Renewal :: Finished at GST=" << duration_hours << ", Duration=" << duration_hours << " h" << std::endl;
|
||||
}
|
||||
@ -1400,7 +1400,7 @@ std::vector<uint8_t> osnma_msg_receiver::build_message(Tag& tag) const
|
||||
// Add applicable NavData bits to message
|
||||
std::string applicable_nav_data = d_nav_data_manager->get_navigation_data(tag);
|
||||
std::vector<uint8_t> applicable_nav_data_bytes = d_helper->bytes(applicable_nav_data);
|
||||
tag.nav_data = applicable_nav_data; // update tag with applicable data
|
||||
tag.nav_data = std::move(applicable_nav_data); // update tag with applicable data
|
||||
|
||||
// Convert and add OSNMA_NavData bytes into the message, taking care of that NMAS has only 2 bits
|
||||
for (uint8_t byte : applicable_nav_data_bytes)
|
||||
@ -1619,11 +1619,11 @@ bool osnma_msg_receiver::verify_macseq(const MACK_message& mack)
|
||||
// Assign relevant sequence based on subframe time
|
||||
if (mack.TOW % 60 < 30) // tried GST_Sf and it does not support the data present.
|
||||
{
|
||||
applicable_sequence = sq1;
|
||||
applicable_sequence = std::move(sq1);
|
||||
}
|
||||
else if (mack.TOW % 60 >= 30)
|
||||
{
|
||||
applicable_sequence = sq2;
|
||||
applicable_sequence = std::move(sq2);
|
||||
}
|
||||
if (mack.tag_and_info.size() != applicable_sequence.size() - 1)
|
||||
{
|
||||
@ -1864,11 +1864,11 @@ std::vector<MACK_tag_and_info> osnma_msg_receiver::verify_macseq_new(const MACK_
|
||||
// Assign relevant sequence based on subframe time
|
||||
if (mack.TOW % 60 < 30) // tried GST_Sf and it does not support the data present.
|
||||
{
|
||||
applicable_sequence = sq1;
|
||||
applicable_sequence = std::move(sq1);
|
||||
}
|
||||
else if (mack.TOW % 60 >= 30)
|
||||
{
|
||||
applicable_sequence = sq2;
|
||||
applicable_sequence = std::move(sq2);
|
||||
}
|
||||
if (mack.tag_and_info.size() != applicable_sequence.size() - 1)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
#if USE_GNUTLS_FALLBACK
|
||||
#include <cstring>
|
||||
@ -625,7 +626,7 @@ std::vector<uint8_t> Gnss_Crypto::compute_HMAC_SHA_256(const std::vector<uint8_t
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free(mac);
|
||||
hmac.resize(output_length);
|
||||
output = hmac;
|
||||
output = std::move(hmac);
|
||||
#else // OpenSSL 1.x
|
||||
unsigned int outputLength = EVP_MAX_MD_SIZE;
|
||||
unsigned char* result = HMAC(EVP_sha256(), key.data(), key.size(), input.data(), input.size(), output.data(), &outputLength);
|
||||
@ -739,7 +740,7 @@ std::vector<uint8_t> Gnss_Crypto::compute_CMAC_AES(const std::vector<uint8_t>& k
|
||||
EVP_MAC_free(mac);
|
||||
|
||||
aux.resize(output_length);
|
||||
output = aux;
|
||||
output = std::move(aux);
|
||||
#else // OpenSSL 1.x
|
||||
size_t mac_length = 0; // to hold the length of the MAC output
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
class GnssCryptoTest : public ::testing::Test
|
||||
{
|
||||
@ -296,7 +297,7 @@ TEST(GnssCryptoTest, VerifySignatureP256)
|
||||
d_crypto->set_public_key(publicKey);
|
||||
ASSERT_TRUE(d_crypto->verify_signature_ecdsa_p256(message, signature));
|
||||
|
||||
std::vector<uint8_t> wrong_signature = signature;
|
||||
std::vector<uint8_t> wrong_signature = std::move(signature);
|
||||
wrong_signature[1] = 1;
|
||||
ASSERT_FALSE(d_crypto->verify_signature_ecdsa_p256(message, wrong_signature));
|
||||
}
|
||||
@ -340,7 +341,7 @@ TEST(GnssCryptoTest, VerifySignatureP521)
|
||||
d_crypto->set_public_key(publicKey);
|
||||
ASSERT_TRUE(d_crypto->verify_signature_ecdsa_p521(message, signature));
|
||||
|
||||
std::vector<uint8_t> wrong_signature = signature;
|
||||
std::vector<uint8_t> wrong_signature = std::move(signature);
|
||||
wrong_signature[1] = 1;
|
||||
ASSERT_FALSE(d_crypto->verify_signature_ecdsa_p521(message, wrong_signature));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user