diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppStun.cpp | 8 | ||||
| -rw-r--r-- | src/QXmppStun.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/QXmppStun.cpp b/src/QXmppStun.cpp index 0c2443db..5bebb379 100644 --- a/src/QXmppStun.cpp +++ b/src/QXmppStun.cpp @@ -661,7 +661,7 @@ QByteArray QXmppStunMessage::encode(const QString &password, bool addFingerprint /// /// \param buffer -quint16 QXmppStunMessage::peekType(const QByteArray &buffer, QByteArray &id) +quint16 QXmppStunMessage::peekType(const QByteArray &buffer, quint32 &cookie, QByteArray &id) { if (buffer.size() < STUN_HEADER) return 0; @@ -670,7 +670,6 @@ quint16 QXmppStunMessage::peekType(const QByteArray &buffer, QByteArray &id) QDataStream stream(buffer); quint16 type; quint16 length; - quint32 cookie; stream >> type; stream >> length; stream >> cookie; @@ -1033,9 +1032,10 @@ void QXmppIceComponent::readyRead() socket->readDatagram(buffer.data(), buffer.size(), &remoteHost, &remotePort); // if this is not a STUN message, emit it + quint32 messageCookie; QByteArray messageId; - quint16 messageType = QXmppStunMessage::peekType(buffer, messageId); - if (!messageType) + quint16 messageType = QXmppStunMessage::peekType(buffer, messageCookie, messageId); + if (!messageType || messageCookie != STUN_MAGIC) { // use this as an opportunity to flag a potential pair if (!m_fallbackPair) { diff --git a/src/QXmppStun.h b/src/QXmppStun.h index 8e70cf9a..71081b26 100644 --- a/src/QXmppStun.h +++ b/src/QXmppStun.h @@ -77,7 +77,7 @@ public: QByteArray encode(const QString &password = QString(), bool addFingerprint = true) const; bool decode(const QByteArray &buffer, const QString &password = QString(), QStringList *errors = 0); QString toString() const; - static quint16 peekType(const QByteArray &buffer, QByteArray &id); + static quint16 peekType(const QByteArray &buffer, quint32 &cookie, QByteArray &id); // attributes int errorCode; |
