@@ -94,25 +94,28 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
9494
9595 if (!WiFi.enableAP (true )) {
9696 // enable AP failed
97+ log_e (" enable AP first!" );
9798 return false ;
9899 }
99100
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!" );
102104 return false ;
103105 }
104106
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!" );
107110 return false ;
108111 }
109112
110113 esp_wifi_start ();
111114
112115 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 ) );
114117 conf.ap .channel = channel;
115- conf.ap .ssid_len = strlen (ssid);
118+ conf.ap .ssid_len = strlen (reinterpret_cast < char *>(conf. ap . ssid ) );
116119 conf.ap .ssid_hidden = ssid_hidden;
117120 conf.ap .max_connection = max_connection;
118121 conf.ap .beacon_interval = 100 ;
@@ -122,7 +125,7 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
122125 *conf.ap .password = 0 ;
123126 } else {
124127 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 ) );
126129 }
127130
128131 wifi_config_t conf_current;
0 commit comments