aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-06-04 00:19:20 -0400
committerMike Frysinger <vapier@gentoo.org>2009-06-04 00:19:20 -0400
commit70f148095b7b9acd4e8329da0766aadc88b017d8 (patch)
treef9c69308721da245f85bf0f09dfffc6234d9ab61 /libsandbox/wrapper-funcs/__openat_2.c
parentlibsandbox: make sure fopen64 uses 64bit funcs (diff)
downloadsandbox-70f148095b7b9acd4e8329da0766aadc88b017d8.tar.gz
sandbox-70f148095b7b9acd4e8329da0766aadc88b017d8.tar.bz2
sandbox-70f148095b7b9acd4e8329da0766aadc88b017d8.zip
libsandbox: add pre checks to static tracing
The normal wrapped functions go through some "pre checks" where certain normal conditions are not flagged as problematic. The static tracing lacked those pre checks though. URL: http://bugs.gentoo.org/265885 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Daniel Robbins <drobbins@funtoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs/__openat_2.c')
-rw-r--r--libsandbox/wrapper-funcs/__openat_2.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/libsandbox/wrapper-funcs/__openat_2.c b/libsandbox/wrapper-funcs/__openat_2.c
index b7a6e09..4549a23 100644
--- a/libsandbox/wrapper-funcs/__openat_2.c
+++ b/libsandbox/wrapper-funcs/__openat_2.c
@@ -9,40 +9,16 @@
# define WRAPPER_ARGS_PROTO int dirfd, const char *pathname, int flags
# define WRAPPER_ARGS dirfd, pathname, flags
# define WRAPPER_SAFE() SB_SAFE_OPEN_INT_AT(dirfd, pathname, flags)
-# define USE_AT 1
#else
-# define USE_AT 0
+# define dirfd AT_FDCWD
#endif
-#ifndef PRE_CHECK_FUNC
-# define _PRE_CHECK_FUNC(x) sb_##x##_pre_check
-# define PRE_CHECK_FUNC(x) _PRE_CHECK_FUNC(x)
-#endif
-static inline bool PRE_CHECK_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_PROTO)
-{
- if (!(flags & O_CREAT)) {
- /* If we're not trying to create, fail normally if
- * file does not stat
- */
-#if USE_AT
- if (dirfd == AT_FDCWD || pathname[0] == '/')
+#ifdef SB64
+# define WRAPPER_PRE_CHECKS() sb_openat64_pre_check(STRING_NAME, pathname, dirfd, flags)
+#else
+# define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags)
#endif
-#undef USE_AT
- {
- struct stat st;
- save_errno();
- if (-1 == stat(pathname, &st)) {
- if (is_env_on(ENV_SANDBOX_DEBUG))
- SB_EINFO("EARLY FAIL", " %s(%s): %s\n",
- STRING_NAME, pathname, strerror(errno));
- return false;
- }
- restore_errno();
- }
- }
-
- return true;
-}
-#define WRAPPER_PRE_CHECKS() PRE_CHECK_FUNC(WRAPPER_NAME)(WRAPPER_ARGS)
#include "__wrapper_simple.c"
+
+#undef dirfd