summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-09-14 15:58:56 -0700
committerShentubot <shentubot@google.com>2018-09-14 16:00:02 -0700
commit3aa50f18a4102429aa40f5d0e518357ceaed2373 (patch)
treecdfb1357173ac3dd4f1cb9f91002896d50b3c47a /pkg/sentry/fs
parentd7a05b4e63252006818e1aadf7a0d383d130fe54 (diff)
Reuse readlink parameter, add sockaddr max.
PiperOrigin-RevId: 213058623 Change-Id: I522598c655d633b9330990951ff1c54d1023ec29
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r--pkg/sentry/fs/host/util_unsafe.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/sentry/fs/host/util_unsafe.go b/pkg/sentry/fs/host/util_unsafe.go
index c38d2392d..2ecb54319 100644
--- a/pkg/sentry/fs/host/util_unsafe.go
+++ b/pkg/sentry/fs/host/util_unsafe.go
@@ -23,6 +23,9 @@ import (
ktime "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/time"
)
+// NulByte is a single NUL byte. It is passed to readlinkat as an empty string.
+var NulByte byte = '\x00'
+
func createLink(fd int, name string, linkName string) error {
namePtr, err := syscall.BytePtrFromString(name)
if err != nil {
@@ -50,7 +53,7 @@ func readLink(fd int) (string, error) {
n, _, errno := syscall.Syscall6(
syscall.SYS_READLINKAT,
uintptr(fd),
- uintptr(unsafe.Pointer(syscall.StringBytePtr(""))),
+ uintptr(unsafe.Pointer(&NulByte)), // ""
uintptr(unsafe.Pointer(&b[0])),
uintptr(l),
0, 0)