diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2023-10-13 02:29:55 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-12 14:29:55 -0700 |
| commit | 1cac5d983de408ced3c05a98a6745d1077e7c1e0 (patch) | |
| tree | 68afa8db614baa2ef7296276b32c15fc52d74149 /weed/filer/filer.go | |
| parent | edee91ef0eb7f7612ae961ac1d1ace2afbd92b87 (diff) | |
| download | seaweedfs-1cac5d983de408ced3c05a98a6745d1077e7c1e0.tar.xz seaweedfs-1cac5d983de408ced3c05a98a6745d1077e7c1e0.zip | |
fix: disallow file name too long when writing a file (#4881)
* fix: disallow file name too long when writing a file
* bool LongerName to MaxFilenameLength
---------
Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
Diffstat (limited to 'weed/filer/filer.go')
| -rw-r--r-- | weed/filer/filer.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go index fdc425f07..239263ca8 100644 --- a/weed/filer/filer.go +++ b/weed/filer/filer.go @@ -50,9 +50,10 @@ type Filer struct { FilerConf *FilerConf RemoteStorage *FilerRemoteStorage Dlm *lock_manager.DistributedLockManager + MaxFilenameLength uint32 } -func NewFiler(masters pb.ServerDiscovery, grpcDialOption grpc.DialOption, filerHost pb.ServerAddress, filerGroup string, collection string, replication string, dataCenter string, notifyFn func()) *Filer { +func NewFiler(masters pb.ServerDiscovery, grpcDialOption grpc.DialOption, filerHost pb.ServerAddress, filerGroup string, collection string, replication string, dataCenter string, maxFilenameLength uint32, notifyFn func()) *Filer { f := &Filer{ MasterClient: wdclient.NewMasterClient(grpcDialOption, filerGroup, cluster.FilerType, filerHost, dataCenter, "", masters), fileIdDeletionQueue: util.NewUnboundedQueue(), @@ -61,6 +62,7 @@ func NewFiler(masters pb.ServerDiscovery, grpcDialOption grpc.DialOption, filerH RemoteStorage: NewFilerRemoteStorage(), UniqueFilerId: util.RandomInt32(), Dlm: lock_manager.NewDistributedLockManager(filerHost), + MaxFilenameLength: maxFilenameLength, } if f.UniqueFilerId < 0 { f.UniqueFilerId = -f.UniqueFilerId @@ -194,12 +196,16 @@ func (f *Filer) RollbackTransaction(ctx context.Context) error { return f.Store.RollbackTransaction(ctx) } -func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool, isFromOtherCluster bool, signatures []int32, skipCreateParentDir bool) error { +func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool, isFromOtherCluster bool, signatures []int32, skipCreateParentDir bool, maxFilenameLength uint32) error { if string(entry.FullPath) == "/" { return nil } + if entry.FullPath.IsLongerFileName(maxFilenameLength) { + return fmt.Errorf("entry name too long") + } + oldEntry, _ := f.FindEntry(ctx, entry.FullPath) /* |
