From ba46f32c804e665741a6db6f2578a01045304d14 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Sun, 30 Mar 2014 22:31:53 +0200 Subject: deploy some asserts to detect truncated STREAM_SEEK_TO_END Since STREAM_SEEK_TO_END is now 64 bits it could happen that some existing code uses it in some indirect manner and it gets truncated to 32 bits somewhere (on 32 bit platforms); try to detect that with asserts. Of course the checked value is now a valid stream position, so perhaps the checks should eventually be removed. Change-Id: I4248c00d758220bdc3ee94c7aa7a7bd4c86c57f0 --- sot/source/sdstor/stgstrms.cxx | 2 ++ sot/source/sdstor/ucbstorage.cxx | 3 +++ 2 files changed, 5 insertions(+) (limited to 'sot') diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index fcd196131761..214b32ebda52 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -1283,6 +1283,8 @@ sal_uLong StgTmpStrm::PutData( const void* pData, sal_uLong n ) sal_uInt64 StgTmpStrm::SeekPos(sal_uInt64 n) { + // check if a truncated STREAM_SEEK_TO_END was passed + assert(n != (sal_uInt64)(sal_uInt32)STREAM_SEEK_TO_END); if( n == STREAM_SEEK_TO_END ) n = GetSize(); if( n && n > THRESHOLD && !pStrm ) diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 8c0be298bfb7..deb5303eb1b4 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -941,6 +941,9 @@ sal_uLong UCBStorageStream_Impl::PutData( const void* pData, sal_uLong nSize ) sal_uInt64 UCBStorageStream_Impl::SeekPos(sal_uInt64 const nPos) { + // check if a truncated STREAM_SEEK_TO_END was passed + assert(nPos != (sal_uInt64)(sal_uInt32)STREAM_SEEK_TO_END); + if( !Init() ) return 0; -- cgit v1.2.3