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:
David du Colombier 2013-12-19 00:58:23 +01:00
parent 93e4a9d84c
commit 674606503e
1 changed files with 7 additions and 0 deletions

View File

@ -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)