1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-21 12:33:15 +00:00

Add protection to crazy HAS data

This commit is contained in:
Carles Fernandez 2021-09-16 18:19:18 +02:00
parent 5b4218a37e
commit 58d508623b
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -30,6 +30,7 @@
#include <cstddef> // size_t
#include <numeric> // std::accumulate
#include <sstream> // std::stringstream
#include <stdexcept> // std::out_of_range
#include <typeinfo> // typeid
#if HAS_GENERIC_LAMBDA
@ -275,8 +276,21 @@ int galileo_e6_has_msg_receiver::decode_message_type1(uint8_t message_id, uint8_
}
read_MT1_header(decoded_message_type_1.substr(0, GALILEO_CNAV_MT1_HEADER_BITS));
read_MT1_body(std::string(decoded_message_type_1.begin() + GALILEO_CNAV_MT1_HEADER_BITS, decoded_message_type_1.end()));
try
{
read_MT1_body(std::string(decoded_message_type_1.begin() + GALILEO_CNAV_MT1_HEADER_BITS, decoded_message_type_1.end()));
}
catch (const std::out_of_range& oor)
{
std::cerr << "Out of Range error when reading HAS messages: " << oor.what() << '\n';
return -1;
}
catch (const std::bad_alloc& e)
{
std::cerr << "Allocation failed when reading HAS messages: " << e.what() << '\n';
return -1;
}
return 0;
}