Also filter out some other obviously invalid filenames (ref #1243)
This commit is contained in:
parent
6213c4f2cd
commit
d02158c0ef
|
@ -490,8 +490,9 @@ func (c *rawConnection) handleIndexUpdate(im IndexMessage) {
|
||||||
func filterIndexMessageFiles(fs []FileInfo) []FileInfo {
|
func filterIndexMessageFiles(fs []FileInfo) []FileInfo {
|
||||||
var out []FileInfo
|
var out []FileInfo
|
||||||
for i, f := range fs {
|
for i, f := range fs {
|
||||||
if f.Name == "" {
|
switch f.Name {
|
||||||
l.Infoln("Dropping nil filename from incoming index")
|
case "", ".", "..", "/": // A few obviously invalid filenames
|
||||||
|
l.Infof("Dropping invalid filename %q from incoming index", f.Name)
|
||||||
if out == nil {
|
if out == nil {
|
||||||
// Most incoming updates won't contain anything invalid, so we
|
// Most incoming updates won't contain anything invalid, so we
|
||||||
// delay the allocation and copy to output slice until we
|
// delay the allocation and copy to output slice until we
|
||||||
|
@ -500,10 +501,12 @@ func filterIndexMessageFiles(fs []FileInfo) []FileInfo {
|
||||||
out = make([]FileInfo, i, len(fs)-1)
|
out = make([]FileInfo, i, len(fs)-1)
|
||||||
copy(out, fs)
|
copy(out, fs)
|
||||||
}
|
}
|
||||||
} else if out != nil {
|
default:
|
||||||
|
if out != nil {
|
||||||
out = append(out, f)
|
out = append(out, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if out != nil {
|
if out != nil {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue