Skip to content

Commit b3d708d

Browse files
jerome-pouillerjhedberg
authored andcommitted
wiseconnect: Use native Posix functions
sl_strlen() and sl_strnlen() can be safely replaced by Posix equivalents. Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent bacbc6c commit b3d708d

File tree

1 file changed

+18
-18
lines changed
  • wiseconnect/components/protocol/wifi/si91x

1 file changed

+18
-18
lines changed

wiseconnect/components/protocol/wifi/si91x/sl_wifi.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -560,45 +560,45 @@ sl_status_t sli_handle_enterprise_security(const sl_wifi_client_configuration_t
560560

561561
memcpy(&(eap_req->user_identity[1]), cred.eap.username, 63);
562562
memcpy(&(eap_req->password[1]), cred.eap.password, 127);
563-
uint8_t uid_len = (uint8_t)sl_strnlen((char *)eap_req->user_identity, 64);
564-
uint8_t psk_len = (uint8_t)sl_strnlen((char *)eap_req->password, 128);
563+
uint8_t uid_len = (uint8_t)strnlen((char *)eap_req->user_identity, 64);
564+
uint8_t psk_len = (uint8_t)strnlen((char *)eap_req->password, 128);
565565
eap_req->user_identity[uid_len] = '"';
566566
eap_req->password[psk_len] = '"';
567567
eap_req->user_identity[uid_len + 1] = 0;
568568
eap_req->password[psk_len + 1] = 0;
569569

570-
if ((SL_WIFI_EAP_TLS_ENCRYPTION == ap->encryption) && (sizeof(eap_req->eap_method) > sl_strlen(SL_EAP_TLS_METHOD))) {
571-
memcpy(eap_req->eap_method, SL_EAP_TLS_METHOD, sl_strlen(SL_EAP_TLS_METHOD));
570+
if ((SL_WIFI_EAP_TLS_ENCRYPTION == ap->encryption) && (sizeof(eap_req->eap_method) > strlen(SL_EAP_TLS_METHOD))) {
571+
memcpy(eap_req->eap_method, SL_EAP_TLS_METHOD, strlen(SL_EAP_TLS_METHOD));
572572
} else if ((SL_WIFI_EAP_TTLS_ENCRYPTION == ap->encryption)
573-
&& (sizeof(eap_req->eap_method) > sl_strlen(SL_EAP_TTLS_METHOD))) {
574-
memcpy(eap_req->eap_method, SL_EAP_TTLS_METHOD, sl_strlen(SL_EAP_TTLS_METHOD));
573+
&& (sizeof(eap_req->eap_method) > strlen(SL_EAP_TTLS_METHOD))) {
574+
memcpy(eap_req->eap_method, SL_EAP_TTLS_METHOD, strlen(SL_EAP_TTLS_METHOD));
575575
} else if ((SL_WIFI_EAP_FAST_ENCRYPTION == ap->encryption)
576-
&& (sizeof(eap_req->eap_method) > sl_strlen(SL_EAP_FAST_METHOD))) {
577-
memcpy(eap_req->eap_method, SL_EAP_FAST_METHOD, sl_strlen(SL_EAP_FAST_METHOD));
576+
&& (sizeof(eap_req->eap_method) > strlen(SL_EAP_FAST_METHOD))) {
577+
memcpy(eap_req->eap_method, SL_EAP_FAST_METHOD, strlen(SL_EAP_FAST_METHOD));
578578
} else if ((SL_WIFI_PEAP_MSCHAPV2_ENCRYPTION == ap->encryption)
579-
&& (sizeof(eap_req->eap_method) > sl_strlen(SL_EAP_PEAP_METHOD))) {
580-
memcpy(eap_req->eap_method, SL_EAP_PEAP_METHOD, sl_strlen(SL_EAP_PEAP_METHOD));
579+
&& (sizeof(eap_req->eap_method) > strlen(SL_EAP_PEAP_METHOD))) {
580+
memcpy(eap_req->eap_method, SL_EAP_PEAP_METHOD, strlen(SL_EAP_PEAP_METHOD));
581581
} else if ((SL_WIFI_EAP_LEAP_ENCRYPTION == ap->encryption)
582-
&& (sizeof(eap_req->eap_method) > sl_strlen(SL_EAP_LEAP_METHOD))) {
583-
memcpy(eap_req->eap_method, SL_EAP_LEAP_METHOD, sl_strlen(SL_EAP_LEAP_METHOD));
582+
&& (sizeof(eap_req->eap_method) > strlen(SL_EAP_LEAP_METHOD))) {
583+
memcpy(eap_req->eap_method, SL_EAP_LEAP_METHOD, strlen(SL_EAP_LEAP_METHOD));
584584
} else {
585585
return SL_STATUS_WIFI_INVALID_ENCRYPTION_METHOD;
586586
}
587587

588-
if (sizeof(eap_req->inner_method) > sl_strlen(SL_EAP_INNER_METHOD)) {
589-
memcpy(eap_req->inner_method, SL_EAP_INNER_METHOD, sl_strlen(SL_EAP_INNER_METHOD));
588+
if (sizeof(eap_req->inner_method) > strlen(SL_EAP_INNER_METHOD)) {
589+
memcpy(eap_req->inner_method, SL_EAP_INNER_METHOD, strlen(SL_EAP_INNER_METHOD));
590590
}
591591
memcpy(eap_req->okc_enable, &cred.eap.eap_flags, sizeof(cred.eap.eap_flags));
592592

593-
uint8_t key_len = (uint8_t)sl_strnlen((char *)cred.eap.certificate_key, SL_WIFI_EAP_CERTIFICATE_KEY_LENGTH);
593+
uint8_t key_len = (uint8_t)strnlen((char *)cred.eap.certificate_key, SL_WIFI_EAP_CERTIFICATE_KEY_LENGTH);
594594
if (key_len > 0) {
595595
eap_req->private_key_password[0] = '"';
596596
if (sizeof(eap_req->private_key_password) > sizeof(cred.eap.certificate_key)) {
597597
memcpy(eap_req->private_key_password, cred.eap.certificate_key, sizeof(cred.eap.certificate_key));
598598
}
599599
eap_req->private_key_password[key_len + 1] = '"';
600-
} else if (sizeof(eap_req->private_key_password) > sl_strlen(SL_DEFAULT_PRIVATE_KEY_PASSWORD)) {
601-
memcpy(eap_req->private_key_password, SL_DEFAULT_PRIVATE_KEY_PASSWORD, sl_strlen(SL_DEFAULT_PRIVATE_KEY_PASSWORD));
600+
} else if (sizeof(eap_req->private_key_password) > strlen(SL_DEFAULT_PRIVATE_KEY_PASSWORD)) {
601+
memcpy(eap_req->private_key_password, SL_DEFAULT_PRIVATE_KEY_PASSWORD, strlen(SL_DEFAULT_PRIVATE_KEY_PASSWORD));
602602
}
603603

604604
return sli_si91x_driver_send_command(SLI_WLAN_REQ_EAP_CONFIG,
@@ -1141,7 +1141,7 @@ sl_status_t sl_wifi_get_pairwise_master_key(sl_wifi_interface_t interface,
11411141
}
11421142

11431143
pairwise_master_key_request.type = type;
1144-
memcpy(pairwise_master_key_request.psk_or_pmk, pre_shared_key, sl_strlen((char *)pre_shared_key));
1144+
memcpy(pairwise_master_key_request.psk_or_pmk, pre_shared_key, strlen((char *)pre_shared_key));
11451145
memcpy(pairwise_master_key_request.ap_ssid, ssid->value, ssid->length);
11461146

11471147
status = sli_si91x_driver_send_command(SLI_WLAN_REQ_HOST_PSK,

0 commit comments

Comments
 (0)