Do not crash on invalid lines

This commit is contained in:
Julian Kornberger
2015-12-28 00:09:00 +01:00
parent f780314026
commit 107079411b
2 changed files with 7 additions and 4 deletions

10
ftp.go
View File

@@ -403,10 +403,12 @@ func parseDirListLine(line string) (*Entry, error) {
// Try various time formats that DIR might use, and stop when one works.
for _, format := range dirTimeFormats {
e.Time, err = time.Parse(format, line[:len(format)])
if err == nil {
line = line[len(format):]
break
if len(line) > len(format) {
e.Time, err = time.Parse(format, line[:len(format)])
if err == nil {
line = line[len(format):]
break
}
}
}
if err != nil {