Skip to content

Commit dbd0302

Browse files
authored
Fix stringop-truncation Compiler Error On Linux For Salinity Application (#362)
1 parent c214aab commit dbd0302

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/apps/rs232_expander_apps/aanderaa_salinity/user_code/aanderaa_conductivity_sensor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,13 @@ void AanderaaConductivitySensor::checkTypeAndAssign(
505505
void AanderaaConductivitySensor::checkTypeAndAssign(
506506
const char *output, uint16_t length,
507507
AanderaaConductivitySensor::AanderaaConductivityString *value) {
508+
const size_t copy_len = sizeof(AanderaaConductivityString) - 1;
509+
510+
if (length > copy_len) {
511+
return;
512+
}
513+
508514
if (value) {
509-
size_t copy_len = bm_min(length, sizeof(AanderaaConductivityString) - 1);
510515
strncpy(*value, output, copy_len);
511516
(*value)[copy_len] = '\0';
512517
}

0 commit comments

Comments
 (0)