Enforce name length restriction on paths.

NAME_LENGTH must be enforced per component.

PiperOrigin-RevId: 224046749
Change-Id: Iba8105b00d951f2509dc768af58e4110dafbe1c9
This commit is contained in:
Brian Geffon
2018-12-04 14:28:33 -08:00
committed by Shentubot
parent 806e346491
commit 5a6a1eb420
+6
View File
@@ -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