diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 09:36:43 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 09:36:43 -0500 |
commit | ac50fbac377e32b98d2de396f016ea81e8ee9961 (patch) | |
tree | f71882366b98fedf1a88a063103219a4935de926 /builtins/evalfile.c | |
parent | 4539d736f1aff232857a854fd2a68df0c98d9f34 (diff) | |
download | android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.tar.gz android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.tar.bz2 android_external_bash-ac50fbac377e32b98d2de396f016ea81e8ee9961.zip |
Bash-4.3 distribution sources and documentation
Diffstat (limited to 'builtins/evalfile.c')
-rw-r--r-- | builtins/evalfile.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 4d69acb..058d99d 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -109,11 +109,16 @@ _evalfile (filename, flags) GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); # endif #endif - + fd = open (filename, O_RDONLY); if (fd < 0 || (fstat (fd, &finfo) == -1)) { + i = errno; + if (fd >= 0) + close (fd); + errno = i; + file_error_and_exit: if (((flags & FEVAL_ENOENTOK) == 0) || errno != ENOENT) file_error (filename); @@ -133,11 +138,13 @@ file_error_and_exit: if (S_ISDIR (finfo.st_mode)) { (*errfunc) (_("%s: is a directory"), filename); + close (fd); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0) { (*errfunc) (_("%s: not a regular file"), filename); + close (fd); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } @@ -146,6 +153,7 @@ file_error_and_exit: if (file_size != finfo.st_size || file_size + 1 < file_size) { (*errfunc) (_("%s: file is too large"), filename); + close (fd); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } @@ -251,7 +259,7 @@ file_error_and_exit: if (flags & FEVAL_BUILTIN) result = EXECUTION_SUCCESS; - return_val = setjmp (return_catch); + return_val = setjmp_nosigs (return_catch); /* If `return' was seen outside of a function, but in the script, then force parse_and_execute () to clean up. */ |