summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorLuciano Iam <lucianito@gmail.com>2020-04-10 08:26:22 +0200
committerRobin Gareus <robin@gareus.org>2020-04-11 22:30:40 +0200
commitc477a81a7c33d840ca18d4ce20ee041d1f165c89 (patch)
tree54fd5894bb9510f3b2e5b94dee07d6e43789b5b0 /libs
parent731ea79028cb8e0d485b38823510bc471843ab03 (diff)
WebSockets: use lws_strncpy() when available
Diffstat (limited to 'libs')
-rw-r--r--libs/surfaces/websockets/server.cc5
1 files changed, 4 insertions, 1 deletions
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<unsigned char*> (body), len, LWS_WRITE_HTTP) != len) {