Skip to content

Commit 4e44cac

Browse files
Added checks
1 parent 3f8c32c commit 4e44cac

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ void wfx_clear_wifi_provision(void)
156156
* @brief
157157
* Start a JOIN command to the AP - Done by the wfx_rsi task
158158
* @param[in] None
159-
* @return returns SL_STATUS_OK if successful,
160-
* SL_STATUS_INVALID_CONFIGURATION otherwise
159+
* @return returns SL_STATUS_OK if successful
161160
****************************************************************************/
162161
sl_status_t wfx_connect_to_ap(void)
163162
{
164163
VerifyOrReturnError(wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED, SL_STATUS_INVALID_CONFIGURATION);
165-
// TODO: check for '\0' in SSID before printing
166-
ChipLogProgress(DeviceLayer, "Connect to access point: %s", wfx_rsi.sec.ssid);
164+
VerifyOrReturnError(strlen(wfx_rsi.sec.ssid) <= WFX_MAX_SSID_LENGTH, SL_STATUS_HAS_OVERFLOWED);
165+
ChipLogProgress(DeviceLayer, "connect to access point: %s", wfx_rsi.sec.ssid);
167166
WfxEvent_t event;
168167
event.eventType = WFX_EVT_STA_START_JOIN;
169168
WfxPostEvent(&event);

examples/platform/silabs/efr32/rs911x/rsi_if.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,13 @@ void ProcessEvent(WfxEvent_t inEvent)
744744
// is it a scan all or target scan
745745
if (!wfx_rsi.scan_ssid || (wfx_rsi.scan_ssid && strcmp(wfx_rsi.scan_ssid, (char *) scan->ssid) == CMP_SUCCESS))
746746
{
747-
strncpy(ap.ssid, (char *) scan->ssid, MIN(sizeof(ap.ssid), sizeof(scan->ssid)));
747+
// clear structure and calculate size of SSID
748+
memset(ap, 0, sizeof(ap));
749+
strncpy(ap.ssid, (char *) scan->ssid, strnlen(scan->ssid, WFX_MAX_SSID_LENGTH));
748750
ap.security = scan->security_mode;
749751
ap.rssi = (-1) * scan->rssi_val;
750-
configASSERT(sizeof(ap.bssid) >= BSSID_LEN);
751-
configASSERT(sizeof(scan->bssid) >= BSSID_LEN);
752+
753+
VerifyOrDie(sizeof(ap.bssid) == BSSID_LEN && sizeof(scan->bssid) == BSSID_LEN);
752754
memcpy(ap.bssid, scan->bssid, BSSID_LEN);
753755
(*wfx_rsi.scan_cb)(&ap);
754756

@@ -760,13 +762,13 @@ void ProcessEvent(WfxEvent_t inEvent)
760762
}
761763

762764
/* Terminate with end of scan which is no ap sent back */
763-
(*wfx_rsi.scan_cb)((wfx_wifi_scan_result_t *) 0);
764-
wfx_rsi.scan_cb = (void (*)(wfx_wifi_scan_result_t *)) 0;
765+
(*wfx_rsi.scan_cb)((wfx_wifi_scan_result_t *) NULL);
766+
wfx_rsi.scan_cb = NULL;
765767

766768
if (wfx_rsi.scan_ssid)
767769
{
768770
vPortFree(wfx_rsi.scan_ssid);
769-
wfx_rsi.scan_ssid = (char *) 0;
771+
wfx_rsi.scan_ssid = NULL;
770772
}
771773
break;
772774
#endif /* SL_WFX_CONFIG_SCAN */

examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,12 @@ void wfx_clear_wifi_provision(void)
159159
* @brief
160160
* Start a JOIN command to the AP - Done by the wfx_rsi task
161161
* @param[in] None
162-
* @return returns SL_STATUS_OK if successful,
163-
* SL_STATUS_INVALID_CONFIGURATION otherwise
162+
* @return returns SL_STATUS_OK if successful
164163
****************************************************************************/
165164
sl_status_t wfx_connect_to_ap(void)
166165
{
167166
VerifyOrReturnError(wfx_rsi.dev_state & WFX_RSI_ST_STA_PROVISIONED, SL_STATUS_INVALID_CONFIGURATION);
168-
VerifyOrReturnError(strlen(wfx_rsi.sec.ssid) <= WFX_MAX_SSID_LENGTH, SL_STATUS_WOULD_OVERFLOW);
167+
VerifyOrReturnError(strlen(wfx_rsi.sec.ssid) <= WFX_MAX_SSID_LENGTH, SL_STATUS_HAS_OVERFLOWED);
169168
ChipLogProgress(DeviceLayer, "connect to access point: %s", wfx_rsi.sec.ssid);
170169
WfxEvent_t event;
171170
event.eventType = WFX_EVT_STA_START_JOIN;

0 commit comments

Comments
 (0)