-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_length member variable in WiFiManagerParameter object not initialized #1504
Comments
hmm i thought I fixed that already, odd |
I cant get it to blow up at all, got an example or is this hypothetical? Also are you getting a compiler warning, I would have expected one... hmm |
i cant think of a way to reliable unit test this oh well, I dont think will be a major issue needing a patch |
It is not hypothetical. I found it on my existing projects. I didn't include the code as it is a large sketch consisting of multiple files & libraries. Following is an example code to reproduce the issue. #include <WiFiManager.h>
class EspWiFiApplication
{
private:
char _mqtt_server[40];
char _ntp_server[40];
public:
void initialize(int count = 0, /* WiFiManagerParameters* */...);
};
void EspWiFiApplication::initialize(int count, /* WiFiManagerParameters* */...)
{
WiFiManagerParameter custom_mqtt_server("mqtt", "mqtt server", _mqtt_server, 40);
WiFiManagerParameter custom_ntp_server("ntp", "nyp server", _ntp_server, 40);
static WiFiManager wifiManager;
wifiManager.addParameter(&custom_mqtt_server);
wifiManager.addParameter(&custom_ntp_server);
}
EspWiFiApplication app;
char _host_name[40];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("BUG1504 TEST");
WiFiManagerParameter custom_host_name("host", "host name", _host_name, 40);
app.initialize(1, &custom_host_name);
}
void loop() {
// put your main code here, to run repeatedly:
} And the debug output with changes in
It panic'd on the 2nd
Hope this help. With your latest changes |
Hi. Even though I dont really get what this is about, I found that when I have a length = 1 this leads to kernel panic now... At least after reading this thread I just changed the length to 2 and its working again... |
Basic Infos
Generic ESP32 DevKit Module
Hardware
WiFimanager Branch/Release: Master
version=2.0.13-beta
Esp8266/Esp32:
Generic ESP32 DevKit Module
Hardware: ESP32-WROOM-32
Core Version: 2.0.5
Description
_length
member variable inWiFiManagerParameter
object not initialized.Problem description
With the following code:
the constructor of WiFiManagerParameter() doesn't initialize the _length member variable.
If it happened that the
length
parameter to theWiFiManagerParameter
constructor is the same as_length
member variable, then insetValue()
, memory for_value
would not be allocated, resulting in panic in the ensuing code.In 2.0.12-beta, there is no comparison between
_length
member variable andlength
parameter, and_value
is always allocated memory, which is why it doesn't crash in 2.0.12-beta.The text was updated successfully, but these errors were encountered: