aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsandbox/wrapper-funcs/__64_post.h1
-rw-r--r--libsandbox/wrapper-funcs/__64_pre.h1
-rw-r--r--libsandbox/wrapper-funcs/openat_pre_check.c2
-rwxr-xr-xtests/open-2.sh10
-rw-r--r--tests/open.at1
5 files changed, 14 insertions, 1 deletions
diff --git a/libsandbox/wrapper-funcs/__64_post.h b/libsandbox/wrapper-funcs/__64_post.h
index 2fd2182..82d2a16 100644
--- a/libsandbox/wrapper-funcs/__64_post.h
+++ b/libsandbox/wrapper-funcs/__64_post.h
@@ -1,3 +1,4 @@
#undef SB64
#undef stat
+#undef lstat
#undef off_t
diff --git a/libsandbox/wrapper-funcs/__64_pre.h b/libsandbox/wrapper-funcs/__64_pre.h
index 2132110..0b34b25 100644
--- a/libsandbox/wrapper-funcs/__64_pre.h
+++ b/libsandbox/wrapper-funcs/__64_pre.h
@@ -1,3 +1,4 @@
#define SB64
#define stat stat64
+#define lstat lstat64
#define off_t off64_t
diff --git a/libsandbox/wrapper-funcs/openat_pre_check.c b/libsandbox/wrapper-funcs/openat_pre_check.c
index c827ee6..0127708 100644
--- a/libsandbox/wrapper-funcs/openat_pre_check.c
+++ b/libsandbox/wrapper-funcs/openat_pre_check.c
@@ -29,7 +29,7 @@ bool sb_openat_pre_check(const char *func, const char *pathname, int dirfd, int
/* Doesn't exist -> skip permission checks */
struct stat st;
- if (-1 == stat(pathname, &st)) {
+ if (((flags & O_NOFOLLOW) ? lstat(pathname, &st) : stat(pathname, &st)) == -1) {
sb_debug_dyn("EARLY FAIL: %s(%s): %s\n",
func, pathname, strerror(errno));
return false;
diff --git a/tests/open-2.sh b/tests/open-2.sh
new file mode 100755
index 0000000..bba9bee
--- /dev/null
+++ b/tests/open-2.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# make sure we handle open(O_NOFOLLOW) correctly #413441
+
+set -e
+rm -f tgt
+ln -s tgt sym
+open-0 -1,ELOOP sym O_NOFOLLOW 0
+
+touch tgt
+open-0 -1,ELOOP sym O_NOFOLLOW 0
diff --git a/tests/open.at b/tests/open.at
index 081d7d2..d364b4b 100644
--- a/tests/open.at
+++ b/tests/open.at
@@ -1 +1,2 @@
SB_CHECK(1)
+SB_CHECK(2)