summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-28 09:28:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-28 11:44:20 +0200
commita52de700a0092ac547f3cbdc3c14e77b6da37955 (patch)
treec78489bf1e5e59a77e6ec6895b4fa92404f8492b
parent6f04952e6828cf1419b991e82070514bae24896c (diff)
ofz: Integer-overflow in lcl_CalDate
FWIW we have another similar implementation of this as Calendar_hijri::getGregorianDay Change-Id: I785f739d8f69ed0e596c27411cc8c7c58c631866 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122757 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 0ec699d6a7db..73a0d5db7df1 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -155,17 +155,17 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,css::util::DateTi
{
if ( _nJulianDate )
{
- sal_Int32 ka = _nJulianDate;
+ sal_Int64 ka = _nJulianDate;
if ( _nJulianDate >= 2299161 )
{
- sal_Int32 ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 );
- ka = _nJulianDate + 1 + ialp - ( ialp >> 2 );
+ sal_Int64 ialp = static_cast<sal_Int64>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 );
+ ka = ka + 1 + ialp - ( ialp >> 2 );
}
- sal_Int32 kb = ka + 1524;
- sal_Int32 kc = static_cast<sal_Int32>( (static_cast<double>(kb) - 122.1 ) / 365.25 );
- sal_Int32 kd = static_cast<sal_Int32>(static_cast<double>(kc) * 365.25);
- sal_Int32 ke = static_cast<sal_Int32>(static_cast<double>( kb - kd ) / 30.6001 );
- _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - static_cast<sal_Int32>( static_cast<double>(ke) * 30.6001 ));
+ sal_Int64 kb = ka + 1524;
+ sal_Int64 kc = static_cast<sal_Int64>((static_cast<double>(kb) - 122.1) / 365.25);
+ sal_Int64 kd = static_cast<sal_Int64>(static_cast<double>(kc) * 365.25);
+ sal_Int64 ke = static_cast<sal_Int64>(static_cast<double>(kb - kd) / 30.6001);
+ _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - static_cast<sal_Int64>( static_cast<double>(ke) * 30.6001 ));
if ( ke > 13 )
_rDateTime.Month = static_cast<sal_uInt16>(ke - 13);
else