From c477a81a7c33d840ca18d4ce20ee041d1f165c89 Mon Sep 17 00:00:00 2001 From: Luciano Iam Date: Fri, 10 Apr 2020 08:26:22 +0200 Subject: WebSockets: use lws_strncpy() when available --- libs/surfaces/websockets/server.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/surfaces/websockets/server.cc b/libs/surfaces/websockets/server.cc index 7455770a7d..79f0c89b85 100644 --- a/libs/surfaces/websockets/server.cc +++ b/libs/surfaces/websockets/server.cc @@ -389,9 +389,12 @@ WebsocketsServer::send_index_body (Client wsi) std::string index = _resources.scan (); char body[MAX_INDEX_SIZE]; - //lws_strncpy (body, index.c_str (), sizeof(body)); +#if LWS_LIBRARY_VERSION_MAJOR >= 3 + lws_strncpy (body, index.c_str (), sizeof(body)); +#else memset (body, 0, sizeof (body)); strncpy (body, index.c_str (), sizeof(body) - 1); +#endif int len = strlen (body); if (lws_write (wsi, reinterpret_cast (body), len, LWS_WRITE_HTTP) != len) { -- cgit v1.2.3