Commit e7693426 authored by Russ Cox's avatar Russ Cox

nacl: fix zero-length writes

NaCl rejects zero-length write using nil pointer.

R=r
CC=golang-dev
https://golang.org/cl/2237042
parent af12feb8
......@@ -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)
......
// 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment