summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2007-04-17 13:50:35 +0000
committerRüdiger Timm <rt@openoffice.org>2007-04-17 13:50:35 +0000
commitb48ee9302e05e24f10c1e8f91309a6e1ca1ebcfc (patch)
tree424694755ae4ace352d5c47f55f0f715db12f109 /writerperfect
parenta3e35b275e0c3d569c96763a821ab1e68b775c44 (diff)
INTEGRATION: CWS fsfixes06 (1.6.2); FILE MERGED
2007/02/06 12:49:23 fridrich_strba 1.6.2.1: check some integer related issues more tightly
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/source/stream/WPXSvStream.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/writerperfect/source/stream/WPXSvStream.cxx b/writerperfect/source/stream/WPXSvStream.cxx
index 749c1b2e0e64..973fb5ab31d9 100644
--- a/writerperfect/source/stream/WPXSvStream.cxx
+++ b/writerperfect/source/stream/WPXSvStream.cxx
@@ -3,6 +3,7 @@
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <limits>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;
@@ -59,7 +60,12 @@ long WPXSvInputStream::tell()
if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is())
return -1L;
else
- return (long)mxSeekable->getPosition();
+ {
+ sal_Int64 tmpPosition = mxSeekable->getPosition();
+ if ((tmpPosition < 0) || (tmpPosition > (std::numeric_limits<long>::max)()))
+ return -1L;
+ return (long)tmpPosition;
+ }
}
int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
@@ -68,24 +74,28 @@ int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
return -1;
sal_Int64 tmpPosition = mxSeekable->getPosition();
+ if ((tmpPosition < 0) || (tmpPosition > (std::numeric_limits<long>::max)()))
+ return -1;
+
+ sal_Int64 tmpOffset = offset;
if (seekType == WPX_SEEK_CUR)
- offset += tmpPosition;
+ tmpOffset += tmpPosition;
int retVal = 0;
- if (offset < 0)
+ if (tmpOffset < 0)
{
- offset = 0;
+ tmpOffset = 0;
retVal = -1;
}
if (offset > mnLength)
{
- offset = mnLength;
+ tmpOffset = mnLength;
retVal = -1;
}
try
{
- mxSeekable->seek(offset);
+ mxSeekable->seek(tmpOffset);
return retVal;
}
catch (...)