From d02158c0effa009fa4bb61421a868882aad0e470 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 13 Jan 2015 12:28:35 +0100 Subject: [PATCH] Also filter out some other obviously invalid filenames (ref #1243) --- protocol.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/protocol.go b/protocol.go index 5fe7cc34..41470428 100644 --- a/protocol.go +++ b/protocol.go @@ -490,8 +490,9 @@ func (c *rawConnection) handleIndexUpdate(im IndexMessage) { func filterIndexMessageFiles(fs []FileInfo) []FileInfo { var out []FileInfo for i, f := range fs { - if f.Name == "" { - l.Infoln("Dropping nil filename from incoming index") + switch f.Name { + case "", ".", "..", "/": // A few obviously invalid filenames + l.Infof("Dropping invalid filename %q from incoming index", f.Name) if out == nil { // Most incoming updates won't contain anything invalid, so we // delay the allocation and copy to output slice until we @@ -500,8 +501,10 @@ func filterIndexMessageFiles(fs []FileInfo) []FileInfo { out = make([]FileInfo, i, len(fs)-1) copy(out, fs) } - } else if out != nil { - out = append(out, f) + default: + if out != nil { + out = append(out, f) + } } } if out != nil {