@@ -94,25 +94,28 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
94
94
95
95
if (!WiFi.enableAP (true )) {
96
96
// enable AP failed
97
+ log_e (" enable AP first!" );
97
98
return false ;
98
99
}
99
100
100
- if (!ssid || *ssid == 0 || strlen (ssid) > 31 ) {
101
- // fail SSID too long or missing!
101
+ if (!ssid || *ssid == 0 ) {
102
+ // fail SSID missing
103
+ log_e (" SSID missing!" );
102
104
return false ;
103
105
}
104
106
105
- if (passphrase && (strlen (passphrase) > 63 || strlen (passphrase) < 8 )) {
106
- // fail passphrase to long or short!
107
+ if (passphrase && (strlen (passphrase) > 0 && strlen (passphrase) < 8 )) {
108
+ // fail passphrase too short
109
+ log_e (" passphrase too short!" );
107
110
return false ;
108
111
}
109
112
110
113
esp_wifi_start ();
111
114
112
115
wifi_config_t conf;
113
- strcpy (reinterpret_cast <char *>(conf.ap .ssid ), ssid);
116
+ strlcpy (reinterpret_cast <char *>(conf.ap .ssid ), ssid, sizeof (conf. ap . ssid ) );
114
117
conf.ap .channel = channel;
115
- conf.ap .ssid_len = strlen (ssid);
118
+ conf.ap .ssid_len = strlen (reinterpret_cast < char *>(conf. ap . ssid ) );
116
119
conf.ap .ssid_hidden = ssid_hidden;
117
120
conf.ap .max_connection = max_connection;
118
121
conf.ap .beacon_interval = 100 ;
@@ -122,7 +125,7 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
122
125
*conf.ap .password = 0 ;
123
126
} else {
124
127
conf.ap .authmode = WIFI_AUTH_WPA2_PSK;
125
- strcpy (reinterpret_cast <char *>(conf.ap .password ), passphrase);
128
+ strlcpy (reinterpret_cast <char *>(conf.ap .password ), passphrase, sizeof (conf. ap . password ) );
126
129
}
127
130
128
131
wifi_config_t conf_current;
0 commit comments