aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libsandbox/wrapper-funcs/fopen.c')
-rw-r--r--libsandbox/wrapper-funcs/fopen.c7
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