crashtesting: failure on import with bogus values

regression from...

commit 7d8e94444d
Date:   Thu Jan 11 08:47:15 2018 +0200

    convert a<b?a:b to std::min(a,b)

cause old promotion was to the largest type, so with a large 64bit nDiff and
any 32bit nRequestedBytes the nRequestedBytes was promoted to 64bit, found to
be smaller than nDiff, then would fit in 32bit. newer code cast both to 32bit,
resulting in a negative nDiff which was smaller than nRequestedBytes, but going
on to cause havoc.

Change-Id: I9eb5c61302b3dccf5333c4dfbf9ac92ce49585b5
Reviewed-on: https://gerrit.libreoffice.org/48155
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-01-18 20:54:22 +00:00
parent 64c9bda0b9
commit 713b261b59

View File

@@ -210,7 +210,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
nRead = mxZipStream->readBytes (
aData,
std::min<sal_Int32>(nDiff, nRequestedBytes) );
std::min<sal_Int64>(nDiff, nRequestedBytes) );
mnZipCurrent += nRead;