summaryrefslogtreecommitdiff
path: root/system/musl/realpath.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2022-01-08 22:54:14 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2022-04-24 20:51:27 -0500
commit91f445a97de176741bccd65381aa86f2a0df9a0a (patch)
tree7cbb0b31fd3b8ad649fa3d805e93d0b23c91d4da /system/musl/realpath.patch
parentefc291615730d56d48bf8a6f816a39c63d0c7653 (diff)
downloadpackages-91f445a97de176741bccd65381aa86f2a0df9a0a.tar.gz
packages-91f445a97de176741bccd65381aa86f2a0df9a0a.tar.bz2
packages-91f445a97de176741bccd65381aa86f2a0df9a0a.tar.xz
packages-91f445a97de176741bccd65381aa86f2a0df9a0a.zip
system/musl: use original behaviour for realpath
This reverts a change in musl 1.2.2 that causes realpath(3) to return "//" for "//" instead of "/". This does not conform to any other OS behaviour other than z/OS. Upstream is still considering which behaviour is correct. Fixes: #446 Upstream-URL: https://www.openwall.com/lists/musl/2021/01/13/1 Suggested-by: Samuel Holland <samuel@sholland.org> Acked-by: Zach van Rijn <me@zv.io>
Diffstat (limited to 'system/musl/realpath.patch')
-rw-r--r--system/musl/realpath.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/system/musl/realpath.patch b/system/musl/realpath.patch
new file mode 100644
index 000000000..25d685918
--- /dev/null
+++ b/system/musl/realpath.patch
@@ -0,0 +1,37 @@
+From 99b84a793669c69acc705a61d339441b50bd09a8 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 13 Jan 2021 14:28:35 +0100
+Subject: [PATCH] realpath: replace leading // with a single /
+
+On some systems a leading double slash may have special meaning, so
+POSIX[1] says that "If a pathname begins with two successive <slash>
+characters, the first component following the leading <slash> characters
+may be interpreted in an implementation-defined manner"
+
+While current musl implementation is technically correct, most other
+systems' (at least GNU libc, freebsd, openbsd, netbsd macOS)
+implementations will replace a leading // with a single /. Make musl
+do the same to avoid surprises.
+
+[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
+---
+ src/misc/realpath.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/misc/realpath.c b/src/misc/realpath.c
+index db8b74dc..414b4741 100644
+--- a/src/misc/realpath.c
++++ b/src/misc/realpath.c
+@@ -46,9 +46,6 @@ restart:
+ q=0;
+ output[q++] = '/';
+ p++;
+- /* Initial // is special. */
+- if (stack[p] == '/' && stack[p+1] != '/')
+- output[q++] = '/';
+ continue;
+ }
+
+--
+2.29.2
+