summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-23 06:43:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-23 06:43:22 -0700
commit56a3bfb691828a0cec5f3156c553efd8253fa914 (patch)
tree1e3660a0473bfdd6c42bf3a5d87d3e9ef2565a3a /parser.c
parent1067252f091ca438d19929523baaa0f8bf6a51cb (diff)
downloadtxr-56a3bfb691828a0cec5f3156c553efd8253fa914.tar.gz
txr-56a3bfb691828a0cec5f3156c553efd8253fa914.tar.bz2
txr-56a3bfb691828a0cec5f3156c553efd8253fa914.zip
Fix race in ~/.txr_profile security check.
* parser.c (load_rcfile): Apply the privacy test to the open stream, rather than the file name, thus guarding against the possibility that a verified file object is replaced by another one before it is opened.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/parser.c b/parser.c
index b56a3d6d..aeaad578 100644
--- a/parser.c
+++ b/parser.c
@@ -382,19 +382,19 @@ static void load_rcfile(val name)
if (!funcall1(path_exists_p, name))
return;
- if (!funcall1(path_private_to_me_p, name)) {
- format(std_output,
- lit("** possible security problem: ~a is writable to others\n"),
- name, nao);
- return;
- }
-
uw_catch_begin (catch_syms, sy, va);
open_txr_file(name, &lisp_p, &resolved_name, &stream);
- if (stream)
+ if (stream) {
+ if (!funcall1(path_private_to_me_p, statf(stream))) {
+ format(std_output,
+ lit("** possible security problem: ~a is writable to others\n"),
+ name, nao);
+ } else {
read_eval_stream(stream, std_output, nil);
+ }
+ }
uw_catch(sy, va)
{