1
0
Fork 0
forked from lthn/blockchain

fixed a potential string copy bug in handle_get_network_state

This commit is contained in:
sowle 2019-03-06 15:16:40 +03:00
parent d785bb2e34
commit f94f402b57

View file

@ -1062,8 +1062,9 @@ namespace nodetool
ce.time_started = cntxt.m_started;
ce.last_recv = cntxt.m_last_recv;
ce.last_send = cntxt.m_last_send;
std::strncpy(ce.version, cntxt.m_remote_version.c_str(), std::min(sizeof(ce.version), cntxt.m_remote_version.size()));
ce.version[sizeof(ce.version) - 1] = 0; //null terminating just to be sure
size_t len = std::min(sizeof(ce.version) - 1, cntxt.m_remote_version.size());
std::strncpy(ce.version, cntxt.m_remote_version.c_str(), len);
ce.version[len] = 0; //null terminating just to be sure
rsp.connections_list.push_back(ce);
return true;
});