@@ -1255,7 +1255,7 @@ webconfig_error_t decode_open_radius_object(const cJSON *radius, wifi_radius_set
12551255}
12561256
12571257webconfig_error_t decode_security_object (const cJSON * security , wifi_vap_security_t * security_info ,
1258- int band )
1258+ int band , wifi_vap_mode_t vap_mode )
12591259{
12601260 const cJSON * param , * object ;
12611261
@@ -1436,15 +1436,18 @@ webconfig_error_t decode_security_object(const cJSON *security, wifi_vap_securit
14361436 return webconfig_error_none ;
14371437 }
14381438
1439- decode_param_string (security , "Passphrase" , param );
1439+ decode_param_allow_empty_string (security , "Passphrase" , param );
14401440
1441- if (security_info -> mode != wifi_security_mode_none &&
1442- (strlen (param -> valuestring ) < MIN_PWD_LEN || strlen (param -> valuestring ) > MAX_PWD_LEN )) {
1443- wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d invalid password length: %d\n" , __func__ ,
1444- __LINE__ , strlen (param -> valuestring ));
1445- return webconfig_error_decode ;
1441+ if (vap_mode != wifi_vap_mode_sta ) {
1442+ if (security_info -> mode != wifi_security_mode_none &&
1443+ (strlen (param -> valuestring ) < MIN_PWD_LEN || strlen (param -> valuestring ) > MAX_PWD_LEN )) {
1444+ wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d invalid password length: %d\n" , __func__ ,
1445+ __LINE__ , strlen (param -> valuestring ));
1446+ return webconfig_error_decode ;
1447+ }
14461448 }
14471449
1450+
14481451 strncpy (security_info -> u .key .key , param -> valuestring , sizeof (security_info -> u .key .key ) - 1 );
14491452
14501453 decode_param_bool (security , "Wpa3_transition_disable" , param );
@@ -1823,7 +1826,7 @@ webconfig_error_t decode_hotspot_open_vap_object(const cJSON *vap, wifi_vap_info
18231826 }
18241827
18251828 decode_param_object (vap , "Security" , security );
1826- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
1829+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
18271830 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
18281831 return webconfig_error_decode ;
18291832 }
@@ -1868,7 +1871,7 @@ webconfig_error_t decode_hotspot_secure_vap_object(const cJSON *vap, wifi_vap_in
18681871 }
18691872
18701873 decode_param_object (vap , "Security" , security );
1871- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
1874+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
18721875 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
18731876 return webconfig_error_decode ;
18741877 }
@@ -1910,7 +1913,7 @@ webconfig_error_t decode_lnf_psk_vap_object(const cJSON *vap, wifi_vap_info_t *v
19101913 }
19111914
19121915 decode_param_object (vap , "Security" , security );
1913- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
1916+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
19141917 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
19151918 return webconfig_error_decode ;
19161919 }
@@ -1955,7 +1958,7 @@ webconfig_error_t decode_lnf_radius_vap_object(const cJSON *vap, wifi_vap_info_t
19551958 }
19561959
19571960 decode_param_object (vap , "Security" , security );
1958- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
1961+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
19591962 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
19601963 return webconfig_error_decode ;
19611964 }
@@ -2001,7 +2004,7 @@ webconfig_error_t decode_iot_vap_object(const cJSON *vap, wifi_vap_info_t *vap_i
20012004 }
20022005
20032006 decode_param_object (vap , "Security" , security );
2004- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
2007+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
20052008 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
20062009 return webconfig_error_decode ;
20072010 }
@@ -2047,7 +2050,7 @@ webconfig_error_t decode_mesh_backhaul_vap_object(const cJSON *vap, wifi_vap_inf
20472050 }
20482051
20492052 decode_param_object (vap , "Security" , security );
2050- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
2053+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
20512054 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
20522055 return webconfig_error_decode ;
20532056 }
@@ -2093,7 +2096,7 @@ webconfig_error_t decode_private_vap_object(const cJSON *vap, wifi_vap_info_t *v
20932096 }
20942097
20952098 decode_param_object (vap , "Security" , security );
2096- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
2099+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
20972100 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
20982101 return webconfig_error_decode ;
20992102 }
@@ -2147,7 +2150,7 @@ webconfig_error_t decode_wifiapi_vap_object(const cJSON *vap, wifi_vap_info_t *v
21472150 }
21482151
21492152 decode_param_object (vap , "Security" , security );
2150- if (decode_security_object (security , & vap_info -> u .bss_info .security , band ) != webconfig_error_none ) {
2153+ if (decode_security_object (security , & vap_info -> u .bss_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
21512154 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
21522155 return webconfig_error_decode ;
21532156 }
@@ -2254,7 +2257,7 @@ webconfig_error_t decode_mesh_sta_object(const cJSON *vap, wifi_vap_info_t *vap_
22542257 }
22552258
22562259 decode_param_object (vap , "Security" , security );
2257- if (decode_security_object (security , & vap_info -> u .sta_info .security , band ) != webconfig_error_none ) {
2260+ if (decode_security_object (security , & vap_info -> u .sta_info .security , band , vap_info -> vap_mode ) != webconfig_error_none ) {
22582261 wifi_util_error_print (WIFI_WEBCONFIG , "%s:%d: Security objects validation failed for %s\n" ,__FUNCTION__ , __LINE__ , vap_info -> vap_name );
22592262 return webconfig_error_decode ;
22602263 }
0 commit comments