summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-19 10:23:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-19 11:01:07 +0000
commit319524767ea1f399be6a9491eb053a74abf3dd1e (patch)
treea16bc4832ff41584b455232e4a45d6f6099dc5d1 /package
parentc3aec587d8fdbdada5a9e26595e7b29e4e6a2920 (diff)
coverity#1242675 Untrusted value as argument
Change-Id: I1d8f32095f297919dc3ccab51093295f8c31707d
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/ZipFile.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index cd4ed2e7491f..bb178f5a8ef5 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -660,11 +660,16 @@ bool ZipFile::readLOC( ZipEntry &rEntry )
try
{
+ sal_Int16 nPathLenToRead = nPathLen;
+ const sal_Int64 nBytesAvailable = aGrabber.getLength() - aGrabber.getPosition();
+ if (nPathLenToRead > nBytesAvailable)
+ nPathLenToRead = nBytesAvailable;
+
// read always in UTF8, some tools seem not to set UTF8 bit
- uno::Sequence < sal_Int8 > aNameBuffer( nPathLen );
- sal_Int32 nRead = aGrabber.readBytes( aNameBuffer, nPathLen );
- if ( nRead < aNameBuffer.getLength() )
- aNameBuffer.realloc( nRead );
+ uno::Sequence<sal_Int8> aNameBuffer(nPathLenToRead);
+ sal_Int32 nRead = aGrabber.readBytes(aNameBuffer, nPathLenToRead);
+ if (nRead < aNameBuffer.getLength())
+ aNameBuffer.realloc(nRead);
OUString sLOCPath = OUString::intern( (sal_Char *) aNameBuffer.getArray(),
aNameBuffer.getLength(),