]> Cypherpunks repositories - gostls13.git/commitdiff
os: Plan 9: allocate space for a string in Rename
authorAkshat Kumar <seed@mail.nanosouffle.net>
Thu, 28 Feb 2013 22:20:42 +0000 (14:20 -0800)
committerRob Pike <r@golang.org>
Thu, 28 Feb 2013 22:20:42 +0000 (14:20 -0800)
The Name field of the stat structure is variable length
and the marshalling code in package syscall requires
a buf long enough to contain the Name as well as the
static data. This change makes sure that the buffer in
os.Rename is allocated with the appropriate length.

R=rsc, rminnich, ality, r
CC=golang-dev
https://golang.org/cl/7453044

src/pkg/os/file_plan9.go

index 595275af2022589cb9f3c35832cfc4b8505ad550..d6d39a89973570e4ef73d27a619b335dfccd3a34 100644 (file)
@@ -308,7 +308,7 @@ func Rename(oldname, newname string) error {
        d.Null()
        d.Name = newname
 
-       var buf [syscall.STATFIXLEN]byte
+       buf := make([]byte, syscall.STATFIXLEN+len(d.Name))
        n, err := d.Marshal(buf[:])
        if err != nil {
                return &PathError{"rename", oldname, err}