Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on malformed quoted printable strings in decode() #1

Open
ghost opened this issue Feb 10, 2013 · 1 comment
Open

Crash on malformed quoted printable strings in decode() #1

ghost opened this issue Feb 10, 2013 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 10, 2013

Test case:

void testQuotedPrintable()
{
    QString malformed = QString::fromLatin1("=40=");
    QuotedPrintable::decode(malformed);
}

Since this code:

        if (input.at(i).toAscii() == '=')
        {
            output->append((hexVal[input.at(++i).toAscii() - '0'] << 4) + hexVal[input.at(++i).toAscii() - '0']);
        }

never checks the length of the input string, input.at(++i) may access the data outside of the string, sometimes resulting in a crash.

********* Start testing of Test *********
Config: Using QTest library 4.8.3, Qt 4.8.3
PASS   : Test::initTestCase()
QFATAL : Test::testQuotedPrintable() ASSERT: "uint(i) < uint(size())" in file /usr/include/qt4/QtCore/qstring.h, line 699
FAIL!  : Test::testQuotedPrintable() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 1 passed, 1 failed, 0 skipped
********* Finished testing of Test *********
@ghost
Copy link
Author

ghost commented Feb 10, 2013

Another issue is that when the function tries to decode a malformed string (like '=\xFF\xFF'), it goes out of hexVal array bounds.

While this possibly won't crash the application (unless the stack is almost exhausted), combined with another attack this may allow the attacker to read the data from the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants