From cfc784a152ebbc4fc0b8bf13c02e0f6eb9c980bd Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Thu, 27 Mar 2025 16:22:38 -0700 Subject: os: avoid panic in Root when symlink references the root We would panic when opening a symlink ending in .., where the symlink references the root itself. Fixes #73081 Change-Id: I7dc3f041ca79df7942feec58c197fde6881ecae5 Reviewed-on: https://go-review.googlesource.com/c/go/+/661416 Reviewed-by: Alan Donovan LUCI-TryBot-Result: Go LUCI --- src/os/root_openat.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/os/root_openat.go') diff --git a/src/os/root_openat.go b/src/os/root_openat.go index 6591825648..f67794cd72 100644 --- a/src/os/root_openat.go +++ b/src/os/root_openat.go @@ -226,6 +226,9 @@ func doInRoot[T any](r *Root, name string, f func(parent sysfdType, name string) return ret, errPathEscapes } parts = slices.Delete(parts, i-count, end) + if len(parts) == 0 { + parts = []string{"."} + } i = 0 if dirfd != rootfd { syscall.Close(dirfd) -- cgit v1.3