summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2017-06-20 02:54:31 -0700
committerJuergen Gehring <juergen.gehring@bmw.de>2017-06-20 02:54:31 -0700
commitfdf86239b4a6867e0a961a307649a6d5eb3a2f93 (patch)
treeb25be00a044a41135d11ddd3f15c1adce3a6411b /tools
parent27698301f8bb528c2f618af5995865523de7e0d6 (diff)
downloadvSomeIP-fdf86239b4a6867e0a961a307649a6d5eb3a2f93.tar.gz
vSomeIP 2.7.02.7.0
Diffstat (limited to 'tools')
-rw-r--r--tools/vsomeip_ctrl.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/vsomeip_ctrl.cpp b/tools/vsomeip_ctrl.cpp
index 9dde00a..1f64c2f 100644
--- a/tools/vsomeip_ctrl.cpp
+++ b/tools/vsomeip_ctrl.cpp
@@ -375,8 +375,10 @@ int main(int argc, char** argv) {
for (unsigned int i = 0; i < message.length(); i += 2) {
vsomeip::byte_t its_byte;
try {
- its_byte = static_cast<vsomeip::byte_t>(std::stoul(
- message.substr(i, 2), 0, 16));
+ std::uint64_t tmp = std::stoul(message.substr(i, 2), 0, 16);
+ tmp = (tmp > (std::numeric_limits<std::uint8_t>::max)()) ?
+ (std::numeric_limits<std::uint8_t>::max)() : tmp;
+ its_byte = static_cast<vsomeip::byte_t>(tmp);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << ": Couldn't convert '"
<< message.substr(i, 2) << "' to hex, exiting: "
@@ -404,8 +406,11 @@ int main(int argc, char** argv) {
for (unsigned int i = 0; i < instance_str.length(); i += 2) {
vsomeip::byte_t its_byte;
try {
- its_byte = static_cast<vsomeip::byte_t>(std::stoul(
- instance_str.substr(i, 2), 0, 16));
+ std::uint64_t tmp = std::stoul(instance_str.substr(i, 2), 0, 16);
+ tmp = (tmp > (std::numeric_limits<std::uint8_t>::max)()) ?
+ (std::numeric_limits<std::uint8_t>::max)() : tmp;
+ its_byte = static_cast<vsomeip::byte_t>(tmp);
+ its_byte = static_cast<vsomeip::byte_t>(tmp);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << ": Couldn't convert '"
<< instance_str.substr(i, 2) << "' to hex, exiting: "
@@ -433,4 +438,5 @@ int main(int argc, char** argv) {
}
vsomeip_ctrl::vsomeip_sender sender(use_tcp, user_message, instance);
+ return EXIT_SUCCESS;
}