From 6c878f3c5b11288c48cbde92e84f0e8e31390b7c Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Wed, 14 Aug 2024 21:49:26 +0300 Subject: [PATCH] Validate option setting for calibrations. Fix a coverity issue --- common/on-chip-calib.cpp | 6 ++++++ common/option-model.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index d49ca4a047..c0c7d602c2 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -132,6 +132,9 @@ namespace rs2 if( it != _sub->options_metadata.end() ) // Option supported { it->second.set_option( RS2_OPTION_EMITTER_ENABLED, value, ignored_error_message ); + if( it->second.value_as_float() != value ) + throw std::runtime_error( rsutils::string::from() + << "Failed to set laser " << ( value == off_value ? "off" : "on" ) ); } } @@ -143,6 +146,9 @@ namespace rs2 if( it != _sub->options_metadata.end() ) // Option supported { it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, value, ignored_error_message ); + if( it->second.value_as_float() != value ) + throw std::runtime_error( rsutils::string::from() + << "Failed to set laser " << ( value == off_value ? "off" : "on" ) ); } } diff --git a/common/option-model.cpp b/common/option-model.cpp index 087610ab92..1ccac91525 100644 --- a/common/option-model.cpp +++ b/common/option-model.cpp @@ -486,7 +486,7 @@ bool option_model::draw_slider( notifications_model & model, { buff_str = convert_float_str( buff_str, 0.01f ); memset( buff, 0, TEXT_BUFF_SIZE ); - strcpy( buff, buff_str.c_str() ); + strncpy( buff, buff_str.c_str(), TEXT_BUFF_SIZE - 1 ); } edit_value = buff; }