aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/unix/xattr_bsd.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/xattr_bsd.go')
-rw-r--r--vendor/golang.org/x/sys/unix/xattr_bsd.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/vendor/golang.org/x/sys/unix/xattr_bsd.go b/vendor/golang.org/x/sys/unix/xattr_bsd.go
index 663b377..e168793 100644
--- a/vendor/golang.org/x/sys/unix/xattr_bsd.go
+++ b/vendor/golang.org/x/sys/unix/xattr_bsd.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build freebsd || netbsd
-// +build freebsd netbsd
package unix
@@ -36,9 +35,14 @@ func xattrnamespace(fullattr string) (ns int, attr string, err error) {
func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
if len(dest) > idx {
return unsafe.Pointer(&dest[idx])
- } else {
- return unsafe.Pointer(_zero)
}
+ if dest != nil {
+ // extattr_get_file and extattr_list_file treat NULL differently from
+ // a non-NULL pointer of length zero. Preserve the property of nilness,
+ // even if we can't use dest directly.
+ return unsafe.Pointer(&_zero)
+ }
+ return nil
}
// FreeBSD and NetBSD implement their own syscalls to handle extended attributes