summaryrefslogtreecommitdiff
path: root/src/pkg/syscall/dir_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/syscall/dir_plan9.go')
-rw-r--r--src/pkg/syscall/dir_plan9.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pkg/syscall/dir_plan9.go b/src/pkg/syscall/dir_plan9.go
index b7ab4cd10..697bf5499 100644
--- a/src/pkg/syscall/dir_plan9.go
+++ b/src/pkg/syscall/dir_plan9.go
@@ -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.
@@ -53,7 +54,7 @@ var nullDir = Dir{
}
// Null assigns special "don't touch" values to members of d to
-// avoid modifiying them during syscall.Wstat.
+// avoid modifying them during syscall.Wstat.
func (d *Dir) Null() { *d = nullDir }
// Marshal encodes a 9P stat message corresponding to d into b
@@ -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)