aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-18 00:45:50 -0500
committerMike Frysinger <vapier@gentoo.org>2009-02-18 00:45:50 -0500
commit140a83e17f20e5a6fecc1a73a629aed52e16036a (patch)
treeea47285d2560841d3ee9efcf5c1688fa02dfc886 /libsandbox/wrapper-funcs
parentlibsandbox: tweak errno handling in fopen() wrapper (diff)
downloadsandbox-140a83e17f20e5a6fecc1a73a629aed52e16036a.tar.gz
sandbox-140a83e17f20e5a6fecc1a73a629aed52e16036a.tar.bz2
sandbox-140a83e17f20e5a6fecc1a73a629aed52e16036a.zip
libsandbox: simplify WRAPPER_PRE_CHECKS() a bit
Remove some of the ugly indirection in the WRAPPER_PRE_CHECKS() defines so it operates like a normal C function -- much easier to work with those. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r--libsandbox/wrapper-funcs/__wrapper_simple.c13
-rw-r--r--libsandbox/wrapper-funcs/fopen.c2
-rw-r--r--libsandbox/wrapper-funcs/mkdirat.c4
-rw-r--r--libsandbox/wrapper-funcs/unlinkat.c4
4 files changed, 13 insertions, 10 deletions
diff --git a/libsandbox/wrapper-funcs/__wrapper_simple.c b/libsandbox/wrapper-funcs/__wrapper_simple.c
index 8bdc22b..b4f0328 100644
--- a/libsandbox/wrapper-funcs/__wrapper_simple.c
+++ b/libsandbox/wrapper-funcs/__wrapper_simple.c
@@ -15,7 +15,7 @@
# define WRAPPER_RET_DEFAULT -1
#endif
#ifndef WRAPPER_PRE_CHECKS
-# define WRAPPER_PRE_CHECKS()
+# define WRAPPER_PRE_CHECKS() true
#endif
extern WRAPPER_RET_TYPE EXTERN_NAME(WRAPPER_ARGS_PROTO);
@@ -25,12 +25,11 @@ WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO)
{
WRAPPER_RET_TYPE result = WRAPPER_RET_DEFAULT;
- WRAPPER_PRE_CHECKS();
-
- if (WRAPPER_SAFE()) {
- check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, WRAPPER_SYMVER);
- result = WRAPPER_TRUE_NAME(WRAPPER_ARGS);
- }
+ if (WRAPPER_PRE_CHECKS())
+ if (WRAPPER_SAFE()) {
+ check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, WRAPPER_SYMVER);
+ result = WRAPPER_TRUE_NAME(WRAPPER_ARGS);
+ }
return result;
}
diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c
index 1a157d1..bb848b6 100644
--- a/libsandbox/wrapper-funcs/fopen.c
+++ b/libsandbox/wrapper-funcs/fopen.c
@@ -29,6 +29,6 @@ static inline bool sb_fopen_pre_check(WRAPPER_ARGS_PROTO)
return true;
}
#endif
-#define WRAPPER_PRE_CHECKS() if (!sb_fopen_pre_check(WRAPPER_ARGS)) return result;
+#define WRAPPER_PRE_CHECKS() sb_fopen_pre_check(WRAPPER_ARGS)
#include "__wrapper_simple.c"
diff --git a/libsandbox/wrapper-funcs/mkdirat.c b/libsandbox/wrapper-funcs/mkdirat.c
index defe569..82ae34d 100644
--- a/libsandbox/wrapper-funcs/mkdirat.c
+++ b/libsandbox/wrapper-funcs/mkdirat.c
@@ -14,6 +14,7 @@
static inline bool sb_mkdirat_pre_check(WRAPPER_ARGS_PROTO)
{
char canonic[SB_PATH_MAX];
+
save_errno();
if (-1 == canonicalize(pathname, canonic))
@@ -31,8 +32,9 @@ static inline bool sb_mkdirat_pre_check(WRAPPER_ARGS_PROTO)
}
restore_errno();
+
return true;
}
-#define WRAPPER_PRE_CHECKS() if (!sb_mkdirat_pre_check(WRAPPER_ARGS)) return result;
+#define WRAPPER_PRE_CHECKS() sb_mkdirat_pre_check(WRAPPER_ARGS)
#include "__wrapper_simple.c"
diff --git a/libsandbox/wrapper-funcs/unlinkat.c b/libsandbox/wrapper-funcs/unlinkat.c
index caf0ab9..8c57f48 100644
--- a/libsandbox/wrapper-funcs/unlinkat.c
+++ b/libsandbox/wrapper-funcs/unlinkat.c
@@ -14,6 +14,7 @@
static inline bool sb_unlinkat_pre_check(WRAPPER_ARGS_PROTO)
{
char canonic[SB_PATH_MAX];
+
save_errno();
if (-1 == canonicalize(pathname, canonic))
@@ -31,8 +32,9 @@ static inline bool sb_unlinkat_pre_check(WRAPPER_ARGS_PROTO)
}
restore_errno();
+
return true;
}
-#define WRAPPER_PRE_CHECKS() if (!sb_unlinkat_pre_check(WRAPPER_ARGS)) return result;
+#define WRAPPER_PRE_CHECKS() sb_unlinkat_pre_check(WRAPPER_ARGS)
#include "__wrapper_simple.c"