summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-10-23 12:31:47 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-10-23 12:31:47 +0200
commitbafcde805ce82ae8dfbd0aec6659b2e4fca163de (patch)
tree2836b3431442cbfa6d9b83e088104f497482fc47 /modules
parenta36a99b846ddc6bb499dca9a7dcdecaada8d08b5 (diff)
Remove unneeded strncpy in lws_client.
Pass the String buffer directly, lws_client_connect_via_info will copy them for us.
Diffstat (limited to 'modules')
-rw-r--r--modules/websocket/lws_client.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
index add3931b50..d71d091720 100644
--- a/modules/websocket/lws_client.cpp
+++ b/modules/websocket/lws_client.cpp
@@ -34,10 +34,6 @@
#include "core/io/stream_peer_ssl.h"
#include "tls/mbedtls/wrapper/include/openssl/ssl.h"
-#if defined(MINGW_ENABLED) || defined(_MSC_VER)
-#define strncpy strncpy_s
-#endif
-
Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
ERR_FAIL_COND_V(context != NULL, FAILED);
@@ -80,26 +76,11 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
ERR_FAIL_V(FAILED);
}
- char abuf[1024];
- char hbuf[1024];
- char pbuf[2048];
- String addr_str = (String)addr;
- strncpy(abuf, addr_str.ascii().get_data(), 1023);
- abuf[1023] = '\0';
- strncpy(hbuf, p_host.utf8().get_data(), 1023);
- hbuf[1023] = '\0';
- strncpy(pbuf, p_path.utf8().get_data(), 2047);
- pbuf[2047] = '\0';
-
i.context = context;
if (p_protocols.size() > 0)
i.protocol = _lws_ref->lws_names;
else
i.protocol = NULL;
- i.address = abuf;
- i.host = hbuf;
- i.path = pbuf;
- i.port = p_port;
if (p_ssl) {
i.ssl_connection = LCCSCF_USE_SSL;
@@ -109,7 +90,16 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
i.ssl_connection = 0;
}
+ // This String needs to survive till we call lws_client_connect_via_info
+ String addr_str = (String)addr;
+
+ i.address = addr_str.ascii().get_data();
+ i.host = p_host.utf8().get_data();
+ i.path = p_path.utf8().get_data();
+ i.port = p_port;
+
lws_client_connect_via_info(&i);
+
return OK;
};