Commit e375bfe1 authored by Lorenz Meier's avatar Lorenz Meier

Fixed buffer overflow with auth key

parent 8a33280e
...@@ -539,8 +539,8 @@ void MAVLinkProtocol::sendHeartbeat() ...@@ -539,8 +539,8 @@ void MAVLinkProtocol::sendHeartbeat()
{ {
mavlink_message_t msg; mavlink_message_t msg;
mavlink_auth_key_t auth; 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); memset(auth, 0, sizeof(auth));
strcpy(auth.key, m_authKey.toStdString().c_str()); 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); mavlink_msg_auth_key_encode(getSystemId(), getComponentId(), &msg, &auth);
sendMessage(msg); sendMessage(msg);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment