From 3387c86f0b9e8d3dff1508e7d0c1ae8177e85adc Mon Sep 17 00:00:00 2001 From: Balaji Subramanyam Date: Tue, 25 Aug 2020 17:22:10 -0700 Subject: [PATCH] Fix SSID bug on Cypress Targets --- .../COMPONENT_WHD/interface/WhdSTAInterface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/connectivity/drivers/emac/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/connectivity/drivers/emac/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp index 51c3675245d..b939b340f60 100644 --- a/connectivity/drivers/emac/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp +++ b/connectivity/drivers/emac/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.cpp @@ -299,9 +299,12 @@ nsapi_error_t WhdSTAInterface::connect() // setup ssid whd_ssid_t ssid; - strncpy((char *)ssid.value, _ssid, SSID_NAME_SIZE); - ssid.value[SSID_NAME_SIZE - 1] = '\0'; - ssid.length = strlen((char *)ssid.value); + uint8_t ssid_len; + + memset(&ssid, 0, sizeof(whd_ssid_t)); + ssid_len = strlen(_ssid); + strncpy((char *)ssid.value, _ssid, ssid_len); + ssid.length = ssid_len; // choose network security whd_security_t security = whd_fromsecurity(_security);