[Libreoffice-commits] core.git: sfx2/source
Caolán McNamara
caolanm at redhat.com
Wed Nov 8 11:52:21 UTC 2017
sfx2/source/doc/oleprops.cxx | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
New commits:
commit 1f17927afee6c874348056db7724f9729504720f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Nov 8 09:57:29 2017 +0000
ofz#4106 Integer-overflow
Change-Id: I91109f652bc032811ade350b77d30424b5764ad8
Reviewed-on: https://gerrit.libreoffice.org/44449
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx
index f860d9b5be11..73af67e2a872 100644
--- a/sfx2/source/doc/oleprops.cxx
+++ b/sfx2/source/doc/oleprops.cxx
@@ -21,6 +21,7 @@
#include "oleprops.hxx"
#include <comphelper/types.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <tools/datetime.hxx>
#include <rtl/tencinfo.h>
@@ -561,19 +562,25 @@ void SfxOleDateProperty::ImplLoad( SvStream& rStrm )
double fValue(0.0);
rStrm.ReadDouble( fValue );
//stored as number of days (not seconds) since December 31, 1899
- ::Date aDate(31, 12, 1899);
- long nDays = fValue;
- aDate.AddDays( nDays );
- maDate.Day = aDate.GetDay();
- maDate.Month = aDate.GetMonth();
- maDate.Year = aDate.GetYear();
+ sal_Int32 nDays = fValue;
+ sal_Int32 nStartDays = ::Date::DateToDays(31, 12, 1899);
+ if (o3tl::checked_add(nStartDays, nDays, nStartDays))
+ SAL_WARN("sfx.doc", "SfxOleDateProperty::ImplLoad bad date, ignored");
+ else
+ {
+ ::Date aDate(31, 12, 1899);
+ aDate.AddDays(nDays);
+ maDate.Day = aDate.GetDay();
+ maDate.Month = aDate.GetMonth();
+ maDate.Year = aDate.GetYear();
+ }
}
void SfxOleDateProperty::ImplSave( SvStream& rStrm )
{
- long nDays = ::Date::DateToDays(maDate.Day, maDate.Month, maDate.Year);
+ sal_Int32 nDays = ::Date::DateToDays(maDate.Day, maDate.Month, maDate.Year);
//number of days (not seconds) since December 31, 1899
- long nStartDays = ::Date::DateToDays(31, 12, 1899);
+ sal_Int32 nStartDays = ::Date::DateToDays(31, 12, 1899);
double fValue = nDays-nStartDays;
rStrm.WriteDouble( fValue );
}
More information about the Libreoffice-commits
mailing list