p2p: fix GCC 9.1 crash

This commit is contained in:
moneromooo-monero 2019-06-08 15:58:09 +00:00
parent 256f8d8b66
commit 4cff9257e0
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -134,10 +134,11 @@ namespace boost
a & port; a & port;
a & length; a & length;
if (length > net::tor_address::buffer_size()) const size_t buffer_size = net::tor_address::buffer_size();
if (length > buffer_size)
MONERO_THROW(net::error::invalid_tor_address, "Tor address too long"); MONERO_THROW(net::error::invalid_tor_address, "Tor address too long");
char host[net::tor_address::buffer_size()] = {0}; char host[buffer_size] = {0};
a.load_binary(host, length); a.load_binary(host, length);
host[sizeof(host) - 1] = 0; host[sizeof(host) - 1] = 0;
@ -155,10 +156,11 @@ namespace boost
a & port; a & port;
a & length; a & length;
if (length > net::i2p_address::buffer_size()) const size_t buffer_size = net::i2p_address::buffer_size();
if (length > buffer_size)
MONERO_THROW(net::error::invalid_i2p_address, "i2p address too long"); MONERO_THROW(net::error::invalid_i2p_address, "i2p address too long");
char host[net::i2p_address::buffer_size()] = {0}; char host[buffer_size] = {0};
a.load_binary(host, length); a.load_binary(host, length);
host[sizeof(host) - 1] = 0; host[sizeof(host) - 1] = 0;