1
0
mirror of https://github.com/golang/go synced 2024-11-21 15:24:45 -07:00

nacl: fix zero-length writes

NaCl rejects zero-length write using nil pointer.

R=r
CC=golang-dev
https://golang.org/cl/2237042
This commit is contained in:
Russ Cox 2010-09-19 22:52:30 -04:00
parent af12feb8d5
commit e769342614
2 changed files with 18 additions and 10 deletions

View File

@ -8,6 +8,8 @@ package syscall
const OS = "nacl"
var _zero [1]byte // pointer used for zero-length writes
// Auto-generated
//sys Chmod(path string, mode uint32) (errno int)

View File

@ -1,4 +1,4 @@
// mksyscall.sh -l32 syscall_nacl.go syscall_nacl_386.go
// mksyscall.sh -l32 -nacl syscall_nacl.go syscall_nacl_386.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
@ -35,11 +35,13 @@ func Fstat(fd int, stat *Stat_t) (errno int) {
}
func Getdents(fd int, buf []byte) (n int, errno int) {
var _p0 *byte
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = &buf[0]
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero[0])
}
r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
errno = int(e1)
return
@ -65,11 +67,13 @@ func Open(path string, mode int, perm uint32) (fd int, errno int) {
}
func Read(fd int, p []byte) (n int, errno int) {
var _p0 *byte
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = &p[0]
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero[0])
}
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)))
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
errno = int(e1)
return
@ -89,11 +93,13 @@ func Stat(path string, stat *Stat_t) (errno int) {
}
func Write(fd int, p []byte) (n int, errno int) {
var _p0 *byte
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = &p[0]
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero[0])
}
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)))
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
errno = int(e1)
return