From 26af00a8c334ed8f62cecadbfcff18d0b13004a7 Mon Sep 17 00:00:00 2001 From: badaix Date: Sat, 5 Dec 2015 23:16:39 +0100 Subject: [PATCH] fixed crash if mac address is empty --- client/clientConnection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/clientConnection.cpp b/client/clientConnection.cpp index accc8e4d..aff2f22d 100644 --- a/client/clientConnection.cpp +++ b/client/clientConnection.cpp @@ -46,7 +46,6 @@ void ClientConnection::socketRead(void* _to, size_t _bytes) size_t len = 0; do { -// boost::system::error_code error; len += socket_->read_some(asio::buffer((char*)_to + len, toRead)); //cout << "len: " << len << ", error: " << error << endl; toRead = _bytes - len; @@ -70,8 +69,11 @@ void ClientConnection::start() // setsockopt(socket->native(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); socket_->connect(*iterator); - logO << "My MAC: \"" << getMacAddress(socket_->native()) << "\"\n"; - msg::Hello hello(getMacAddress(socket_->native())); + std::string mac = getMacAddress(socket_->native()); + if (mac.empty()) + mac = "00:00:00:00:00:00"; + logO << "My MAC: \"" << mac << "\"\n"; + msg::Hello hello(mac); send(&hello); connected_ = true; logS(kLogNotice) << "Connected to " << socket_->remote_endpoint().address().to_string() << endl;