summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/binaryformat.cpp
diff options
context:
space:
mode:
authorkh <karsten.heimrich@theqtcompany.com>2014-11-28 16:41:15 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2014-12-01 16:11:55 +0100
commit52e176b4a40d55b84aac762b77da5262687f6503 (patch)
tree221c07797e1edf60a40951e496beedb0d4cb15cd /src/libs/installer/binaryformat.cpp
parenta439e6fab484461744a657f5173a738622064edf (diff)
Fix online installation into directory with elevated permissions.
Inside the Resource class we can't use QFile, as that will access the elevated running server to read from a only client side mapped file. Adjust Resource::readData to behave properly with the file engine's nativeRead(...) implementation, e.g. on Unix it returns -1 if called to read with a size of 0 bytes. Do not write to the socket if we are running in a different thread than the one the socket was created in. Fix logically broken connect function. Task-number: QTIFW-572 Change-Id: I993b5d3a5c217b0aedbbc27837dce2619e51d224 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Takayuki ORITO <iori.ayane@gmail.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/binaryformat.cpp')
-rw-r--r--src/libs/installer/binaryformat.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 9cf7ef28a..015e21b2f 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -197,9 +197,14 @@ qint64 Resource::size() const
*/
qint64 Resource::readData(char* data, qint64 maxSize)
{
+ // check if there is anything left to read
+ maxSize = qMin<quint64>(maxSize, m_segment.length() - pos());
+ if (maxSize <= 0)
+ return 0;
+
const qint64 p = m_file.pos();
m_file.seek(m_segment.start() + pos());
- const qint64 amountRead = m_file.read(data, qMin<quint64>(maxSize, m_segment.length() - pos()));
+ const qint64 amountRead = m_file.read(data, maxSize);
m_file.seek(p);
return amountRead;
}