@@ -82,14 +82,10 @@ static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL,
82
82
wifi_config->sta .ssid [0 ] = 0 ;
83
83
wifi_config->sta .password [0 ] = 0 ;
84
84
if (ssid != NULL && ssid[0 ] != 0 ){
85
- snprintf ((char *)wifi_config->sta .ssid , 32 , ssid );
85
+ strncpy ((char *)wifi_config->sta .ssid , ssid, 32 );
86
86
if (password != NULL && password[0 ] != 0 ){
87
87
wifi_config->sta .threshold .authmode = WIFI_AUTH_WEP;
88
- if (strlen (password) == 64 ){
89
- memcpy ((char *)wifi_config->sta .password , password, 64 );
90
- } else {
91
- snprintf ((char *)wifi_config->sta .password , 64 , password);
92
- }
88
+ strncpy ((char *)wifi_config->sta .password , password, 64 );
93
89
}
94
90
if (bssid != NULL ){
95
91
wifi_config->sta .bssid_set = 1 ;
@@ -165,15 +161,11 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
165
161
166
162
wifi_config_t conf;
167
163
memset (&conf, 0 , sizeof (wifi_config_t ));
168
- strcpy (reinterpret_cast <char *>(conf.sta .ssid ), ssid);
164
+ strncpy (reinterpret_cast <char *>(conf.sta .ssid ), ssid, 32 );
169
165
conf.sta .scan_method = WIFI_ALL_CHANNEL_SCAN; // force full scan to be able to choose the nearest / strongest AP
170
166
171
167
if (passphrase) {
172
- if (strlen (passphrase) == 64 ){ // it's not a passphrase, is the PSK
173
- memcpy (reinterpret_cast <char *>(conf.sta .password ), passphrase, 64 );
174
- } else {
175
- strcpy (reinterpret_cast <char *>(conf.sta .password ), passphrase);
176
- }
168
+ strncpy (reinterpret_cast <char *>(conf.sta .password ), passphrase, 64 );
177
169
}
178
170
179
171
wifi_config_t current_conf;
0 commit comments