Skip to content

Commit 3ab9005

Browse files
committed
Make sure host_metrics user_string is null terminated
1 parent aabc5b7 commit 3ab9005

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/modules/Telemetry/HostMetrics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ meshtastic_Telemetry HostMetricsModule::getHostMetrics()
111111
if (settingsStrings[hostMetrics_user_command] != "") {
112112
std::string userCommandResult = exec(settingsStrings[hostMetrics_user_command].c_str());
113113
if (userCommandResult.length() > 1) {
114-
strncpy(t.variant.host_metrics.user_string, userCommandResult.c_str(), 200);
114+
strncpy(t.variant.host_metrics.user_string, userCommandResult.c_str(), sizeof(t.variant.host_metrics.user_string));
115+
t.variant.host_metrics.user_string[ sizeof(t.variant.host_metrics.user_string) - 1] = '\0';
115116
t.variant.host_metrics.has_user_string = true;
116117
}
117118
}

0 commit comments

Comments
 (0)