diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-02-18 00:43:14 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-02-18 00:43:14 -0500 |
commit | 90df3741ced48554bcd113dc40599b8ea2972e1a (patch) | |
tree | 64e4f795f932e1c8948b4996c8fd5694ce78b758 | |
parent | libsandbox: do save/restore errno in sym lookup (diff) | |
download | sandbox-90df3741ced48554bcd113dc40599b8ea2972e1a.tar.gz sandbox-90df3741ced48554bcd113dc40599b8ea2972e1a.tar.bz2 sandbox-90df3741ced48554bcd113dc40599b8ea2972e1a.zip |
libsandbox: tweak errno handling in fopen() wrapper
No point in saving/restoring the errno value if we don't make any C lib
function calls.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | libsandbox/wrapper-funcs/fopen.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c index 18c5a7f..1a157d1 100644 --- a/libsandbox/wrapper-funcs/fopen.c +++ b/libsandbox/wrapper-funcs/fopen.c @@ -15,14 +15,17 @@ #define SB_FOPEN_PRE_CHECK static inline bool sb_fopen_pre_check(WRAPPER_ARGS_PROTO) { - save_errno(); if ((NULL != mode) && (mode[0] == 'r')) { + save_errno(); + /* If we're trying to read, fail normally if file does not stat */ struct stat st; if (-1 == stat(pathname, &st)) return false; + + restore_errno(); } - restore_errno(); + return true; } #endif |