From 971a04f1dcbbb044b43fd74746d42e1539053b9b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 1 Jul 2010 17:49:28 -0700 Subject: [PATCH] implications of len spec change R=r CC=golang-dev https://golang.org/cl/1712048 --- src/pkg/os/dir_darwin.go | 2 +- src/pkg/os/dir_freebsd.go | 2 +- src/pkg/os/dir_linux.go | 2 +- src/pkg/os/dir_nacl.go | 2 +- src/pkg/syscall/syscall_bsd.go | 4 ++-- src/pkg/syscall/syscall_linux.go | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pkg/os/dir_darwin.go b/src/pkg/os/dir_darwin.go index 7917daec6b9..f9f51221dae 100644 --- a/src/pkg/os/dir_darwin.go +++ b/src/pkg/os/dir_darwin.go @@ -58,7 +58,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) { if dirent.Ino == 0 { // File absent in directory. continue } - bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) var name = string(bytes[0:dirent.Namlen]) if name == "." || name == ".." { // Useless names continue diff --git a/src/pkg/os/dir_freebsd.go b/src/pkg/os/dir_freebsd.go index 7a0290ac6ae..b32c474e692 100644 --- a/src/pkg/os/dir_freebsd.go +++ b/src/pkg/os/dir_freebsd.go @@ -53,7 +53,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) { if dirent.Fileno == 0 { // File absent in directory. continue } - bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) var name = string(bytes[0:dirent.Namlen]) if name == "." || name == ".." { // Useless names continue diff --git a/src/pkg/os/dir_linux.go b/src/pkg/os/dir_linux.go index 84f87007ed3..42cc88a8a77 100644 --- a/src/pkg/os/dir_linux.go +++ b/src/pkg/os/dir_linux.go @@ -56,7 +56,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) { if dirent.Ino == 0 { // File absent in directory. continue } - bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) var name = string(bytes[0:clen(bytes[0:])]) if name == "." || name == ".." { // Useless names continue diff --git a/src/pkg/os/dir_nacl.go b/src/pkg/os/dir_nacl.go index e693794f027..e76b2bea09c 100644 --- a/src/pkg/os/dir_nacl.go +++ b/src/pkg/os/dir_nacl.go @@ -56,7 +56,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) { if dirent.Ino == 0 { // File absent in directory. continue } - bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) var name = string(bytes[0:clen(bytes)]) if name == "." || name == ".." { // Useless names continue diff --git a/src/pkg/syscall/syscall_bsd.go b/src/pkg/syscall/syscall_bsd.go index 14dfab1539f..66be580e7d0 100644 --- a/src/pkg/syscall/syscall_bsd.go +++ b/src/pkg/syscall/syscall_bsd.go @@ -239,8 +239,8 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, int) { break } } - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0])) - sa.Name = string(bytes[0:n]) + bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) return sa, 0 case AF_INET: diff --git a/src/pkg/syscall/syscall_linux.go b/src/pkg/syscall/syscall_linux.go index 2ce3c08828a..8442d8485cb 100644 --- a/src/pkg/syscall/syscall_linux.go +++ b/src/pkg/syscall/syscall_linux.go @@ -284,8 +284,8 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, int) { for n < len(pp.Path) && pp.Path[n] != 0 { n++ } - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0])) - sa.Name = string(bytes[0:n]) + bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) return sa, 0 case AF_INET: