mirror of https://github.com/golang/go.git
syscall: disallow slashes in file names on Plan 9
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/43480050
This commit is contained in:
parent
93e4a9d84c
commit
674606503e
|
|
@ -11,6 +11,7 @@ import "errors"
|
|||
var (
|
||||
ErrShortStat = errors.New("stat buffer too short")
|
||||
ErrBadStat = errors.New("malformed stat buffer")
|
||||
ErrBadName = errors.New("bad character in file name")
|
||||
)
|
||||
|
||||
// A Qid represents a 9P server's unique identification for a file.
|
||||
|
|
@ -65,6 +66,12 @@ func (d *Dir) Marshal(b []byte) (n int, err error) {
|
|||
return n, ErrShortStat
|
||||
}
|
||||
|
||||
for _, c := range d.Name {
|
||||
if c == '/' {
|
||||
return n, ErrBadName
|
||||
}
|
||||
}
|
||||
|
||||
b = pbit16(b, uint16(n)-2)
|
||||
b = pbit16(b, d.Type)
|
||||
b = pbit32(b, d.Dev)
|
||||
|
|
|
|||
Loading…
Reference in New Issue