From b48ee9302e05e24f10c1e8f91309a6e1ca1ebcfc Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Tue, 17 Apr 2007 13:50:35 +0000 Subject: 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 --- writerperfect/source/stream/WPXSvStream.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'writerperfect') 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 #include #include +#include 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::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::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 (...) -- cgit