From 2c95e2981d67367bccc0c091e8fca8b1b155a79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 19 Feb 2024 12:25:59 +0100 Subject: [PATCH] Improve StunPacket::Dump() and CheckAuthentication() --- worker/src/RTC/StunPacket.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/worker/src/RTC/StunPacket.cpp b/worker/src/RTC/StunPacket.cpp index 7cc7de7f0a..c71ef4c00d 100644 --- a/worker/src/RTC/StunPacket.cpp +++ b/worker/src/RTC/StunPacket.cpp @@ -394,14 +394,11 @@ namespace RTC } MS_DUMP(" size: %zu bytes", this->size); - char transactionId[25]; + auto transactionId1 = Utils::Byte::Get4Bytes(this->transactionId, 0); + auto transactionId2 = Utils::Byte::Get8Bytes(this->transactionId, 4); - for (int i{ 0 }; i < 12; ++i) - { - // NOTE: n must be 3 because snprintf adds a \0 after printed chars. - std::snprintf(transactionId + (i * 2), 3, "%.2x", this->transactionId[i]); - } - MS_DUMP(" transactionId: %s", transactionId); + MS_DUMP(" transactionId (first 4 bytes): %" PRIu32, transactionId1); + MS_DUMP(" transactionId (last 8 bytes): %" PRIu64, transactionId2); if (this->errorCode != 0u) { MS_DUMP(" errorCode: %" PRIu16, this->errorCode); @@ -543,6 +540,13 @@ namespace RTC break; } + + default: + { + MS_WARN_TAG(ice, "unknown STUN class %" PRIu16 ", cannot authenticate", this->klass); + + return Authentication::BAD_MESSAGE; + } } // If there is FINGERPRINT it must be discarded for MESSAGE-INTEGRITY