Skip to content

Commit 7ef1911

Browse files
fixup! wui: Replace the SNTP reset with per-pass reconciliation
1 parent 8d583db commit 7ef1911

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/WUI/sntp/sntp_client.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "wui_api.h"
55
#include "tcpip.h"
66

7-
#include <stdio.h>
87
#include <string.h>
98

109
#include <option/has_esp.h>
@@ -64,9 +63,12 @@ void sntp_client_step(void) {
6463
return;
6564
}
6665

67-
snprintf(sntp_applied_server, sizeof(sntp_applied_server), "%s", configured);
68-
6966
LOCK_TCPIP_CORE();
67+
// The copy itself must happen under the lock too: lwIP still holds a
68+
// pointer to this same buffer from the previous start, and the tcpip
69+
// thread may be reading it in an in-flight request. The lock excludes
70+
// that reader while the buffer changes; the restart below re-registers it.
71+
strlcpy(sntp_applied_server, configured, sizeof(sntp_applied_server));
7072
sntp_client_start();
7173
UNLOCK_TCPIP_CORE();
7274
sntp_running = true;

tests/unit/lib/WUI/sntp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function(add_sntp_client_test target stub_dir)
77
${target}
88
# Not really tests, just stuffings to satisfy the linker.
99
${CMAKE_CURRENT_SOURCE_DIR}/missing_functions.c
10+
${CMAKE_SOURCE_DIR}/tests/stubs/strlcpy.c
1011
# The tests.
1112
${CMAKE_CURRENT_SOURCE_DIR}/sntp_client_tests.cpp
1213
# Tested files.

0 commit comments

Comments
 (0)