From 1fc6b70adc396ec89c0f8971b504ea4ea3bd8175 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 28 Dec 2015 12:17:09 +0100 Subject: [PATCH] Another fix for the line parser --- ftp.go | 4 ++++ parse_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/ftp.go b/ftp.go index b334c65..fd3648e 100644 --- a/ftp.go +++ b/ftp.go @@ -347,6 +347,10 @@ func parseLsListLine(line string) (*Entry, error) { return e, nil } + if len(fields) < 8 { + return nil, errUnsupportedListLine + } + if fields[1] == "0" { e := &Entry{ Type: EntryTypeFile, diff --git a/parse_test.go b/parse_test.go index 0d373f7..b442800 100644 --- a/parse_test.go +++ b/parse_test.go @@ -59,6 +59,7 @@ var listTestsFail = []unsupportedLine{ {"modify=20150806235817;invalid;UNIX.owner=0; movies", "Unsupported LIST line"}, {"Zrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin", "Unknown entry type"}, {"total 1", "Unsupported LIST line"}, + {"", "Unsupported LIST line"}, } func TestParseValidListLine(t *testing.T) {