Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#67 closed defect (fixed)

ftp_stat.parse_ms_time breaks on IIS 7.5 with 4 digit year lines

Reported by: ftputiluser Owned by: schwa
Priority: major Milestone: 2.8
Component: Library Version:
Keywords: directory, listing, parser, iis, year Cc:


IIS 7.5 FTP Server displays dates with 4 digit years when in MS-DOS directory style listing mode:

lftp anonymous@localhost:~> ls -l
10-19-2012  03:13PM       <DIR>          SYNCDEST
10-19-2012  03:13PM       <DIR>          SYNCSOURCE

Parser.parse_ms_time in ftp_stat expects a two digit year and breaks on these date lines:

Traceback (most recent call last):
  File "D:\ECLIPSE-WS\ftputilplay\src\", line 131, in <module>
  File "D:\ECLIPSE-WS\ftputilplay\src\", line 128, in main
    sync(config_tree, source_host, target_host)
  File "D:\ECLIPSE-WS\ftputilplay\src\", line 105, in sync
    syncer.sync(,, delete_on_target, use_mtimes, retries, exclude)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 208, in sync
    if self._source.path.isfile(source_path):
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 111, in isfile
    path, _exception_for_missing_path=False)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 896, in stat
    return self._stat._stat(path, _exception_for_missing_path)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 625, in _stat
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 579, in __call_with_parser_retry
    result = method(*args, **kwargs)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 544, in _real_stat
    lstat_result = self._real_lstat(path, _exception_for_missing_path)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 503, in _real_lstat
    for stat_result in self._stat_results_from_dir(dirname):
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 437, in _stat_results_from_dir
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 377, in parse_line
    st_mtime = self.parse_ms_time(date, time_, time_shift)
  File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\", line 252, in parse_ms_time
    hour, minute, 0, 0, 0, -1) )
OverflowError: mktime argument out of range

when it generates a date of 2012+1900=3912 in these lines:

if year >= 70:
    year = 1900 + year
    year = 2000 + year

I've changed the code to:

if year < 100:
    if year >= 70:
        year = 1900 + year
        year = 2000 + year

This should handle most two and four digit case except for four digit years between 0 and 100. But I'm not really concerned about that old files :). A more stable solution could check for the length of the year input string before handling two digit years.

Best regards,


Change History (3)

comment:1 Changed 9 years ago by schwa

Keywords: directory listing parser iis year added
Milestone: 2.7.2
Status: newassigned

Hi Mario, thanks for the report!

I agree with your last statement. In my opinion, it's more straightforward to check the string length of the year part. I'll do it next month, when I have more time.

comment:2 Changed 9 years ago by schwa

Resolution: fixed
Status: assignedclosed

I've checked in a fix as changeset [efd6e56cc4be].

comment:3 Changed 9 years ago by schwa

Note: See TracTickets for help on using tickets.