diff options
| author | Linus Jahn <lnj@kaidan.im> | 2023-03-09 17:36:17 +0100 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2023-03-09 20:07:35 +0100 |
| commit | 18353901a2215376e2f0274a408ce2213c180f16 (patch) | |
| tree | 9fdc9e80206cdea8b35216bcd32ab769e5c97bfb /src/base/QXmppSasl.cpp | |
| parent | 4df9803baf460b4779bcfdecda95708c5c96dab8 (diff) | |
| download | qxmpp-18353901a2215376e2f0274a408ce2213c180f16.tar.gz | |
SaslDigestMd5: Fix UB when at the end of input byte array [Qt6 only]
Also adds a unit test.
Fixes #541.
Diffstat (limited to 'src/base/QXmppSasl.cpp')
| -rw-r--r-- | src/base/QXmppSasl.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/base/QXmppSasl.cpp b/src/base/QXmppSasl.cpp index d8a86bb0..86e67b01 100644 --- a/src/base/QXmppSasl.cpp +++ b/src/base/QXmppSasl.cpp @@ -896,8 +896,12 @@ QMap<QByteArray, QByteArray> QXmppSaslDigestMd5::parseMessage(const QByteArray & const QByteArray key = ba.mid(startIndex, pos - startIndex).trimmed(); pos++; - // check whether string is quoted - if (ba.at(pos) == '"') { + if (pos == ba.size()) { + // end of the input + map.insert(key, QByteArray()); + startIndex = pos; + } else if (ba.at(pos) == '"') { + // check whether string is quoted // skip opening quote pos++; int endPos = ba.indexOf('"', pos); |
