mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Also filter out some other obviously invalid filenames (ref #1243)
This commit is contained in:
parent
25c26e2f81
commit
9a45f0b31c
@ -587,8 +587,9 @@ func ldbWithAllFolderTruncated(db *leveldb.DB, folder []byte, fn func(device []b
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Name == "" {
|
switch f.Name {
|
||||||
l.Infoln("Dropping invalid nil filename from database")
|
case "", ".", "..", "/": // A few obviously invalid filenames
|
||||||
|
l.Infof("Dropping invalid filename %q from database", f.Name)
|
||||||
batch := new(leveldb.Batch)
|
batch := new(leveldb.Batch)
|
||||||
ldbRemoveFromGlobal(db, batch, folder, device, nil)
|
ldbRemoveFromGlobal(db, batch, folder, device, nil)
|
||||||
batch.Delete(dbi.Key())
|
batch.Delete(dbi.Key())
|
||||||
|
@ -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,8 +501,10 @@ 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:
|
||||||
out = append(out, f)
|
if out != nil {
|
||||||
|
out = append(out, f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if out != nil {
|
if out != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user