summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-19 15:07:14 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-19 15:07:14 +0100
commit724f2b20d83c340d9cb1221766a741f432ed9204 (patch)
tree116f8ba78f0fe6e8f7a32d1f86fd4c9d97581738 /comphelper
parent0ae76ce8bac0b1679598f27e5883af1e33f403c6 (diff)
coverity#1373663 Untrusted loop bound
Change-Id: Iabad14f8fc35656015b98693dd327a41aeaf63c7
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index 60ad11a92444..5c55ca4e436f 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -105,14 +105,7 @@ namespace
// read rTarget
if (osl::File::E_None == rFile->read(static_cast<void*>(aArray), 4, nBaseRead) && 4 == nBaseRead)
{
- //This is untainted data which comes from a controlled source
- //so, using a byte-swapping pattern which coverity doesn't
- //detect as such
- //http://security.coverity.com/blog/2014/Apr/on-detecting-heartbleed-with-static-analysis.html
- rTarget = aArray[0]; rTarget <<= 8;
- rTarget |= aArray[1]; rTarget <<= 8;
- rTarget |= aArray[2]; rTarget <<= 8;
- rTarget |= aArray[3];
+ rTarget = (sal_uInt32(aArray[0]) << 24) + (sal_uInt32(aArray[1]) << 16) + (sal_uInt32(aArray[2]) << 8) + sal_uInt32(aArray[3]);
return true;
}
@@ -674,6 +667,13 @@ namespace
return false;
}
+ // coverity#1373663 Untrusted loop bound, check file size
+ // isn't utterly broken
+ sal_uInt64 nFileSize(0);
+ rFile->getSize(nFileSize);
+ if (nFileSize < nExtEntries)
+ return false;
+
for (sal_uInt32 a(0); a < nExtEntries; a++)
{
ExtensionInfoEntry aNewEntry;