If the size of encoded data is wrong, the decode() will cause heap corruption. So suggest that decode() should verify the length of input rrawText. It the lenght is not mutiple of 16 bytes(AES block), return an empty buffer.
Example code:
QByteArray encodedText("123456"); // wrong length
// QByteArray encodedText("1234561234561234"); does not cause failure.
QByteArray hashKey = QCryptographicHash::hash(seed, QCryptographicHash::Sha256);
QByteArray decoded = QAESEncryption::Decrypt(QAESEncryption::AES_128, QAESEncryption::ECB, encodedText, hashKey);
QByteArry res = QAESEncryption::RemovePadding(decoded);
This will cause
HEAP CORRUPTION DETECTED: after Normal block (#42796) at 0x0000023DF89F0770.
CRT detected that the application wrote to memory after end of heap buffer.
If the size of encoded data is wrong, the decode() will cause heap corruption. So suggest that decode() should verify the length of input rrawText. It the lenght is not mutiple of 16 bytes(AES block), return an empty buffer.
Example code:
This will cause