aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-11-26 21:53:24 -0500
committerMike Frysinger <vapier@gentoo.org>2010-11-26 21:53:24 -0500
commit2c90a2dd2d5be3ca593a7bcd8d79e6d0db296204 (patch)
treefd3f6f23fa24f305d9333100507e52174ad9d07d
parenttests: allow dirfds to specify mode too (diff)
downloadsandbox-2c90a2dd2d5be3ca593a7bcd8d79e6d0db296204.tar.gz
sandbox-2c90a2dd2d5be3ca593a7bcd8d79e6d0db296204.tar.bz2
sandbox-2c90a2dd2d5be3ca593a7bcd8d79e6d0db296204.zip
libsandbox: fix utimensat regression with NULL filename
The previous commit (libsandbox: handle dirfd in mkdir/open/unlink *at prechecks) unified some path checks while unifying the dirfd code, but prevented valid NULL paths from also being handled. Make sure we still handle that behavior, and add a test for it to prevent future regressions. URL: http://bugs.gentoo.org/346815 Reported-by: Jake Todd <jaketodd422@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libsandbox/libsandbox.c2
-rwxr-xr-xtests/utimensat-3.sh6
-rw-r--r--tests/utimensat.at1
3 files changed, 8 insertions, 1 deletions
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 908a150..041abe8 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -154,7 +154,7 @@ int resolve_dirfd_path(int dirfd, const char *path, char *resolved_path,
* Since maintaining fd state based on open's is real messy, we'll
* just rely on the kernel doing it for us with /proc/<pid>/fd/ ...
*/
- if (dirfd == AT_FDCWD || !path || path[0] == '/')
+ if (dirfd == AT_FDCWD || (path && path[0] == '/'))
return 1;
save_errno();
diff --git a/tests/utimensat-3.sh b/tests/utimensat-3.sh
new file mode 100755
index 0000000..4ecd4b3
--- /dev/null
+++ b/tests/utimensat-3.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# make sure NULL filename is handled correctly
+
+addwrite $PWD
+
+exec utimensat-0 -1:22 'f:O_WRONLY|O_CREAT:0666' NULL NULL 0
diff --git a/tests/utimensat.at b/tests/utimensat.at
index d364b4b..eec4638 100644
--- a/tests/utimensat.at
+++ b/tests/utimensat.at
@@ -1,2 +1,3 @@
SB_CHECK(1)
SB_CHECK(2)
+SB_CHECK(3)