summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-02-20 01:34:10 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-02-20 01:49:47 +0100
commit2b8b738391ed34b371673e4b62c7bd22e3503e2a (patch)
treeccc36927d744c97fcf21abb6aa604b41e0014a1b /modules
parenta056e8dc7719de24a645d3500d7228d6955372ff (diff)
Small hack to avoid runtime error when using ubsan
mbedtls_ssl_read cannot be called with a NULL buffer even if len is 0, as those are passed to memcpy and compilers doesn't like that. Always pass a single byte (still len 0 so nothing is actually copied)
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/mbedtls/stream_peer_mbed_tls.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/mbedtls/stream_peer_mbed_tls.cpp b/modules/mbedtls/stream_peer_mbed_tls.cpp
index e4050b1af8..45d3b86919 100755
--- a/modules/mbedtls/stream_peer_mbed_tls.cpp
+++ b/modules/mbedtls/stream_peer_mbed_tls.cpp
@@ -270,7 +270,10 @@ void StreamPeerMbedTLS::poll() {
return;
}
- int ret = mbedtls_ssl_read(&ssl, NULL, 0);
+ // We could pass NULL as second parameter, but some behaviour sanitizers doesn't seem to like that.
+ // Passing a 1 byte buffer to workaround it.
+ uint8_t byte;
+ int ret = mbedtls_ssl_read(&ssl, &byte, 0);
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
// Nothing to read/write (non blocking IO)