summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--match.c12
2 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 009b8fa5..2796376d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-02-24 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (v_load): Sanity checking on target path.
+ Check if it is absolute and do not substitute parent
+ file's directory.
+
+2012-02-24 Kaz Kylheku <kaz@kylheku.com>
+
* match.c (h_var): Eliminated uses of rl function, in favor of
rlcp. Only the parser should use rl to establish location info.
diff --git a/match.c b/match.c
index 5f6e6ecc..5691511d 100644
--- a/match.c
+++ b/match.c
@@ -3375,10 +3375,18 @@ static val v_load(match_files_ctx *c)
if (rest(specline))
sem_error(specline, lit("unexpected material after load"), nao);
+ if (!stringp(target))
+ sem_error(specline, lit("load: path ~s is not a string"), target, nao);
+
+ if (equal(target, null_string))
+ sem_error(specline, lit("load: null string path given"), nao);
+
{
- val path = cat_str(nappend2(sub_list(split_str(parent, lit("/")),
+ val path = if3(chr_str(target, zero) == chr('/'),
+ target,
+ cat_str(nappend2(sub_list(split_str(parent, lit("/")),
zero, negone),
- cons(target, nil)), lit("/"));
+ cons(target, nil)), lit("/")));
int gc = gc_state(0);
parse_reset(path);
yyparse();