Commit 05c7f9b3 authored by Eric Duminil's avatar Eric Duminil
Browse files

Safer alternative to strncpy

parent b3843a73
...@@ -231,14 +231,14 @@ namespace web_config { ...@@ -231,14 +231,14 @@ namespace web_config {
sensor_console::defineStringCommand("ssid", [](char *ssid) { sensor_console::defineStringCommand("ssid", [](char *ssid) {
Serial.print(F("Setting WiFi ssid to ")); Serial.print(F("Setting WiFi ssid to "));
Serial.println(ssid); Serial.println(ssid);
strncpy(iotWebConf->getWifiSsidParameter()->valueBuffer, ssid, iotWebConf->getWifiSsidParameter()->getLength()); strlcpy(iotWebConf->getWifiSsidParameter()->valueBuffer, ssid, iotWebConf->getWifiSsidParameter()->getLength());
iotWebConf->saveConfig(); iotWebConf->saveConfig();
}, F("name (Sets SSID to name)")); }, F("name (Sets SSID to name)"));
sensor_console::defineStringCommand("pwd", [](char *ssid) { sensor_console::defineStringCommand("pwd", [](char *ssid) {
Serial.print(F("Setting WiFi password to ")); Serial.print(F("Setting WiFi password to "));
Serial.println(ssid); Serial.println(ssid);
strncpy(iotWebConf->getWifiPasswordParameter()->valueBuffer, ssid, iotWebConf->getWifiPasswordParameter()->getLength()); strlcpy(iotWebConf->getWifiPasswordParameter()->valueBuffer, ssid, iotWebConf->getWifiPasswordParameter()->getLength());
iotWebConf->saveConfig(); iotWebConf->saveConfig();
}, F("abc (Sets WiFi password to abc)")); }, F("abc (Sets WiFi password to abc)"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment