From 4d220882b46d5f8edd4d09e5f66722cd296a092e Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Fri, 5 Jul 2013 12:16:34 +0200 Subject: hair splitting on years in dates in ZIP structure Change-Id: I9d7a6436e3df75eff592d19dcaca0f655ebf2160 --- package/source/zipapi/ZipOutputStream.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'package/source') diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 7b2ae4ffe543..22cc0b320e00 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -450,12 +450,25 @@ sal_uInt32 ZipOutputStream::getCurrentDosTime( ) osl_getSystemTime ( &aTimeValue ); osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime); + // at year 2108, there is an overflow + // -> some decision needs to be made + // how to handle the ZIP file format (just overflow?) + + // if the current system time is before 1980, + // then the time traveller will have to make a decision + // how to handle the ZIP file format before it is invented + // (just underflow?) + + assert(aDateTime.Year > 1980 && aDateTime.Year < 2108); + sal_uInt32 nYear = static_cast (aDateTime.Year); - if (nYear>1980) + if (nYear>=1980) nYear-=1980; - else if (nYear>80) + else if (nYear>=80) + { nYear-=80; + } sal_uInt32 nResult = static_cast < sal_uInt32>( ( ( ( aDateTime.Day) + ( 32 * (aDateTime.Month)) + ( 512 * nYear ) ) << 16) | -- cgit