aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorTim Wright <tenortim@gmail.com>2017-11-04 19:35:23 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2017-11-06 16:36:34 +0000
commit37b15baa3b884d5de8563f91be2afa3659e8258f (patch)
tree0084501cf7f6b9fbb267d9097bad75409e330e3b /src/syscall
parentef0e2af7b0296c61c17877b84f09221335a962f7 (diff)
downloadgo-37b15baa3b884d5de8563f91be2afa3659e8258f.tar.xz
syscall: fix NaCl Link syscall error handling
The existing NaCl filesystem Link system call erroneously allowed a caller to call Link on an existing target which violates the POSIX standard and effectively corrupted the internal filesystem representation. Fixes #22383 Change-Id: I77b16c37af9bf00a1799fa84277f066180edac47 Reviewed-on: https://go-review.googlesource.com/76110 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/fs_nacl.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/syscall/fs_nacl.go b/src/syscall/fs_nacl.go
index cbd9539c92..8fee4daee9 100644
--- a/src/syscall/fs_nacl.go
+++ b/src/syscall/fs_nacl.go
@@ -636,6 +636,10 @@ func Link(path, link string) error {
if ip.Mode&S_IFMT == S_IFDIR {
return EPERM
}
+ _, _, err = fs.dirlookup(dp, elem)
+ if err == nil {
+ return EEXIST
+ }
fs.dirlink(dp, elem, ip)
return nil
}