diff options
author | Brian Geffon <bgeffon@google.com> | 2018-12-04 14:27:46 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-04 14:28:33 -0800 |
commit | 5a6a1eb420620c3d41a9db4ddf7ac7b163310f09 (patch) | |
tree | 7f4c1d4a76498faf9d0318ccf4e92c9d16b4efec /pkg/sentry/fs | |
parent | 806e346491503e0292bcee8bf15d74bbf42e2a10 (diff) |
Enforce name length restriction on paths.
NAME_LENGTH must be enforced per component.
PiperOrigin-RevId: 224046749
Change-Id: Iba8105b00d951f2509dc768af58e4110dafbe1c9
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r-- | pkg/sentry/fs/dirent.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/fs/dirent.go b/pkg/sentry/fs/dirent.go index 4c0d1b7ef..4c0482036 100644 --- a/pkg/sentry/fs/dirent.go +++ b/pkg/sentry/fs/dirent.go @@ -458,6 +458,12 @@ func (d *Dirent) walk(ctx context.Context, root *Dirent, name string, walkMayUnl if !IsDir(d.Inode.StableAttr) { return nil, syscall.ENOTDIR } + + // The component must be less than NAME_MAX. + if len(name) > linux.NAME_MAX { + return nil, syscall.ENAMETOOLONG + } + if name == "" || name == "." { d.IncRef() return d, nil |