Skip to content

Commit

Permalink
Add safety check for qChecksum (nickbnf#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Feb 24, 2021
1 parent 0974b57 commit b4c8548
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 3rdparty/singleapp/src/singleapplication_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
quint16 msgChecksum = 0;
readStream >> msgChecksum;

const quint16 actualChecksum = qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) );

const quint16 actualChecksum =
msgBytes.length() > sizeof( quint16 )
? qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) )
: 0;

bool isValid = readStream.status() == QDataStream::Ok &&
QLatin1String(latin1Name) == blockServerName &&
msgChecksum == actualChecksum;
Expand Down

0 comments on commit b4c8548

Please sign in to comment.