- 
    
Bug
 - 
    Resolution: Done
 - 
    
P2: Important
 - 
    5.12.0 Alpha
 - 
    None
 
- 
        6709c0eecb88a325eba0157214e9c42ac6bd85d7
 
In cases of code points that are encoded with two or more octets in UTF-8
template<>
QString QMqttConnection::readBufferTyped()
{
    const quint16 size = readBufferTyped<quint16>();
    return QString::fromUtf8(reinterpret_cast<const char *>(readBuffer(size).constData()), size);
}
consumes more octets from the buffer than the position tracking in
        case 0x26: { // 3.15.2.2.5 User property
            ...
            const QString propertyValue = readBufferTyped<QString>();
            propertyLength -= propertyValue.length() + 2;
takes care of.
Possible resolution:
    template<class T>
    T QMqttConnection::readBufferTyped(int *remainingLen = nullptr);
  ...
    template<>
    quint16 QMqttConnection::readBufferTyped(int *remainingLen = nullptr)
   {
         const quint16 result =  qFromBigEndian<quint16>(reinterpret_cast<const quint16 *>(readBuffer(2).constData()));
        if (remainingLen)
            *remainingLen -= 2;
         return result;
    }
    ...
     
    template<>
    QString QMqttConnection::readBufferTyped(int *remainingLen = nullptr)
    {
        const quint16 size = readBufferTyped<quint16>(remainingLen);
        const QByteArray ba = reinterpret_cast<const char *>(readBuffer(size).constData()), size);
        if (remainingLen)
            *remainingLen -= ba.size();
        return QString::fromUtf8(ba, size);
    }
| For Gerrit Dashboard: QTBUG-69642 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V | 
| 235741,2 | Move data size calculation to readBufferTyped | dev | qt/qtmqtt | Status: MERGED | +2 | 0 |