From cfd7268bd557c8aef725ad1cb3873947318c9b83 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 4 Sep 2016 19:28:48 +1000 Subject: [PATCH] GCS_MAVLink: check the signing key magic on load or we end up with a bad key when MAVLink2 is first enabled --- libraries/GCS_MAVLink/GCS_Signing.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS_Signing.cpp b/libraries/GCS_MAVLink/GCS_Signing.cpp index 1ee86c4dc2..d5ea9f1f97 100644 --- a/libraries/GCS_MAVLink/GCS_Signing.cpp +++ b/libraries/GCS_MAVLink/GCS_Signing.cpp @@ -53,7 +53,13 @@ bool GCS_MAVLINK::signing_key_load(struct SigningKey &key) if (_signing_storage.size() < sizeof(key)) { return false; } - return _signing_storage.read_block(&key, 0, sizeof(key)); + if (!_signing_storage.read_block(&key, 0, sizeof(key))) { + return false; + } + if (key.magic != SIGNING_KEY_MAGIC) { + return false; + } + return true; } /*