|
22 | 22 | #include <stdio.h>
|
23 | 23 | #include <stdlib.h>
|
24 | 24 | #include <string.h>
|
| 25 | + |
25 | 26 | #if (SL_MATTER_GN_BUILD == 0)
|
26 | 27 | #include "sl_matter_wifi_config.h"
|
27 | 28 | #endif // SL_MATTER_GN_BUILD
|
|
42 | 43 | #include <lib/support/CHIPMemString.h>
|
43 | 44 | #include <lib/support/CodeUtils.h>
|
44 | 45 | #include <lib/support/logging/CHIPLogging.h>
|
45 |
| -#include <platform/CHIPDeviceLayer.h> |
46 | 46 |
|
47 | 47 | extern "C" {
|
48 | 48 | #include "sl_net.h"
|
@@ -542,8 +542,11 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
|
542 | 542 | for (int idx = 0; idx < (int) scan_result->scan_count; idx++)
|
543 | 543 | {
|
544 | 544 | memset(&cur_scan_result, 0, sizeof(cur_scan_result));
|
545 |
| - cur_scan_result.ssid_length = chip::min<size_t>(strnlen((char *) scan_result->scan_info[idx].ssid, chip::DeviceLayer::Internal::kMaxWiFiSSIDLength) + 1, chip::DeviceLayer::Internal::kMaxWiFiSSIDLength); // +1 for null termination |
546 |
| - chip::Platform::CopyString(cur_scan_result.ssid, cur_scan_result.ssid_length, (char *) scan_result->scan_info[idx].ssid); |
| 545 | + |
| 546 | + cur_scan_result.ssid_length = strnlen((char *) scan_result->scan_info[idx].ssid, |
| 547 | + chip::min<size_t>(sizeof(scan_result->scan_info[idx].ssid), WFX_MAX_SSID_LENGTH)); |
| 548 | + chip::Platform::CopyString(cur_scan_result.ssid, cur_scan_result.ssid_length + 1, (char *) scan_result->scan_info[idx].ssid); // +1 for null termination |
| 549 | + |
547 | 550 | // if user has provided ssid, then check if the current scan result ssid matches the user provided ssid
|
548 | 551 | if (wfx_rsi.scan_ssid != NULL &&
|
549 | 552 | (strncmp(wfx_rsi.scan_ssid, cur_scan_result.ssid, MIN(strlen(wfx_rsi.scan_ssid), strlen(cur_scan_result.ssid))) !=
|
@@ -601,7 +604,7 @@ static void wfx_rsi_save_ap_info(void) // translation
|
601 | 604 | sl_wifi_ssid_t ssid_arg;
|
602 | 605 | memset(&ssid_arg, 0, sizeof(ssid_arg));
|
603 | 606 | ssid_arg.length = wfx_rsi.sec.ssid_length;
|
604 |
| - memcpy((char *) &ssid_arg.value[0], wfx_rsi.sec.ssid, ssid_arg.length); |
| 607 | + chip::Platform::CopyString((char *) &ssid_arg.value[0], ssid_arg.length + 1, wfx_rsi.sec.ssid); // +1 for null termination |
605 | 608 | sl_wifi_set_scan_callback(scan_callback_handler, NULL);
|
606 | 609 | scan_results_complete = false;
|
607 | 610 | #ifndef EXP_BOARD
|
|
0 commit comments