Sorry, i found a bug in PdfDate::CreateStringRepresentation(), but 
didn't find any other way to report it
The error lines are commented out and i appended "// Original code !    
(n)" to the corresponding line. n is 1,2,3 or 4
The corrected line is just below the problem line. (4 problem lines)

Sorry i overlooked the bug marked as 3 !
localtime_s(&stm, &m_time ) returns En != 0 on error, En == 0 means NO error

The code :

void PdfDate::CreateStringRepresentation()
{
//    struct tm* stm = NULL;                                     // 
Original code !    (1)
     struct tm stm;
     errno_t En = 0;
     long Tz = 0;

     const int   ZONE_STRING_SIZE = 6;
     const char* INVALIDDATE     = "INVALIDDATE";

     char szZone[ZONE_STRING_SIZE];
     char szDate[PDF_DATE_BUFFER_SIZE];

//    En = localtime_s(stm, &m_time );                                 
// Original code !    (2)
     En = localtime_s(&stm, &m_time );
//    if (! En)                                                     // 
Original code !    (3)
     if (En != 0)
     {
         PODOFO_RAISE_ERROR_INFO( ePdfError_Date,INVALIDDATE );
     }

#ifdef _WIN32
     // On win32, strftime with %z returns a verbose time zone name
     // like "W. Australia Standard time". We use tzset and timezone
     // instead.
     _tzset();
     En = _get_timezone(&Tz);
     _snprintf_s( szZone, ZONE_STRING_SIZE, "%+03d", -Tz/3600 );
#else
     if( strftime( szZone, ZONE_STRING_SIZE, "%z", stm ) == 0 )
     {
         std::ostringstream ss;
         ss << "Generated invalid date from time_t value " << m_time
            << " (couldn't determine time zone)\n";
         PdfError::DebugMessage( ss.str().c_str() );
         strcpy_s( m_szDate, INVALIDDATE );
         return;
     }
#endif

     // only the first 3 characters are important for the pdf date 
representation
     // e.g. +01 instead off +0100
     szZone[3] = '\0';

//    if( strftime( szDate, PDF_DATE_BUFFER_SIZE, "D:%Y%m%d%H%M%S", stm 
) == 0 )            // Original code !    (4)
     if( strftime( szDate, PDF_DATE_BUFFER_SIZE, "D:%Y%m%d%H%M%S", &stm 
) == 0 )
     {
         std::ostringstream ss;
         ss << "Generated invalid date from time_t value " << m_time
            << "\n";
         PdfError::DebugMessage( ss.str().c_str() );
         strcpy_s( m_szDate, INVALIDDATE );
         return;
     }

     _snprintf_s( m_szDate, PDF_DATE_BUFFER_SIZE, "%s%s'00'", szDate, 
szZone );
     m_bValid = true;
}

Cheers,
Marc
marc-de-mul...@skynet.be


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to