Fixed signed int overflow in remotelinux plugin

Change-Id: Icf2a707a0195b1d197b7c965100a783f3e78f52a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Robert Loehning <robert.loehning@nokia.com>
This commit is contained in:
David Schulz
2012-09-03 15:19:45 +02:00
committed by Oswald Buddenhagen
parent ac6ca18ec0
commit c3e7a9b830

View File

@@ -91,6 +91,7 @@ void RemoteLinuxCheckForFreeDiskSpaceService::handleProcessFinished()
QByteArray processOutput = d->processRunner->readAllStandardOutput(); QByteArray processOutput = d->processRunner->readAllStandardOutput();
processOutput.chop(1); // newline processOutput.chop(1); // newline
quint64 freeSpace = processOutput.toULongLong(&isNumber); quint64 freeSpace = processOutput.toULongLong(&isNumber);
quint64 requiredSpaceInMegaBytes = d->requiredSpaceInBytes / (1024 * 1024);
if (!isNumber) { if (!isNumber) {
emit errorMessage(tr("Unexpected output from remote process: '%1'.") emit errorMessage(tr("Unexpected output from remote process: '%1'.")
.arg(QString::fromUtf8(processOutput))); .arg(QString::fromUtf8(processOutput)));
@@ -98,15 +99,15 @@ void RemoteLinuxCheckForFreeDiskSpaceService::handleProcessFinished()
return; return;
} }
freeSpace *= 1024; freeSpace /= 1024; // convert kilobyte to megabyte
if (freeSpace < d->requiredSpaceInBytes) { if (freeSpace < requiredSpaceInMegaBytes) {
emit errorMessage(tr("The remote file system has only %n bytes of free space, " emit errorMessage(tr("The remote file system has only %n megabytes of free space, "
"but %1 bytes are required.", 0, freeSpace).arg(d->requiredSpaceInBytes)); "but %1 megabytes are required.", 0, freeSpace).arg(requiredSpaceInMegaBytes));
stopDeployment(); stopDeployment();
return; return;
} }
emit progressMessage(tr("The remote file system has %n bytes of free space, going ahead.", emit progressMessage(tr("The remote file system has %n megabytes of free space, going ahead.",
0, freeSpace)); 0, freeSpace));
stopDeployment(); stopDeployment();
} }