bricke / Qt-AES

Native Qt AES encryption class
The Unlicense
501 stars 187 forks source link

Question about : Heap corruption detected: after normal block..... #66

Open ShaKing-L opened 5 months ago

ShaKing-L commented 5 months ago

2024-04-13_225321 When using this library for decryption, an out of memory error may occur when the length of the string to be decrypted does not match. It is currently believed that when using the mid() function on QByteArray, it may be necessary to determine if the length limit has been exceeded. Like this:

for (int i = 0; i < rawText.size(); i += m_blocklen)
{
    if (i + m_blocklen > rawText.length()) 
    {
        break;
    }
    ret.append(invCipher(expandedKey, rawText.mid(i, m_blocklen)));
}
break;

I am not good at English, so I use translation tools. Please forgive me.Thank you!😄

bricke commented 5 months ago

Can you write an example of HEAP Corruption? Like what do you mean by "when the length of the string to be decrypted does not match" ?

ShaKing-L commented 5 months ago

If the code /K6O0t1d8dpWZpe8EbBwYgrAiN9o5V5RtUELRJI1IrFqgIzI03yijPlU/PFXlqnWJ7Km+GCNUZoUWO4VszwmgA== can be successfully decode.

When I cut this code like this /K6O0t1d8dpWZpe8EbBwYgrAiN9o5V5RtUELRJI1IrFqgIzI03yijPlU/PFXlqnWJ7Km+GCNUZoUW this error will be reported.

bricke commented 4 months ago

so that is your rawText ?

If so, it's odd as the decode function should return an empty QByteArray if the rawText compatible with the block length. Please, make a sample code that I can easily run so I can see what are you actually triggering.