From e375bfe10162f8c49c0c6ea8351154e19bbd2d66 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 16 Sep 2012 15:51:45 +0200 Subject: [PATCH] Fixed buffer overflow with auth key --- src/comm/MAVLinkProtocol.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index b2ac86f51..bad141735 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -539,8 +539,8 @@ void MAVLinkProtocol::sendHeartbeat() { mavlink_message_t msg; mavlink_auth_key_t auth; - if (m_authKey.length() != MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN) m_authKey.resize(MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN); - strcpy(auth.key, m_authKey.toStdString().c_str()); + memset(auth, 0, sizeof(auth)); + memcpy(auth.key, m_authKey.toStdString().c_str(), qMin(m_authKey.length(), MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN)); mavlink_msg_auth_key_encode(getSystemId(), getComponentId(), &msg, &auth); sendMessage(msg); } -- 2.22.0