aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-11-30 01:06:04 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-11-30 01:06:04 +0000
commit62db676b15fc72064ca036d6890b97698ecbe0eb (patch)
treefb527ceab98953d833bf80840ac45928fd3941c2
parentf42742f10cf8efbf1fe594050003b0ccbf006038 (diff)
downloadpaludis-62db676b15fc72064ca036d6890b97698ecbe0eb.tar.gz
paludis-62db676b15fc72064ca036d6890b97698ecbe0eb.tar.xz
Don't allow newlines in symlink targets for VDB.
-rw-r--r--paludis/repositories/e/vdb_merger.cc7
-rw-r--r--paludis/repositories/e/vdb_merger_TEST.cc10
-rwxr-xr-xpaludis/repositories/e/vdb_merger_TEST_setup.sh16
3 files changed, 25 insertions, 8 deletions
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 24ddf54..d6cdd19 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -278,9 +278,12 @@ VDBMerger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
if (is_check)
{
if (std::string::npos != src.basename().find('\n'))
- throw MergerError("'" + stringify(src) + "Symlink ' contains a newline in its name, which cannot be stored by VDB");
+ throw MergerError("Symlink '" + stringify(src) + "' contains a newline in its name, which cannot be stored by VDB");
+ if (std::string::npos != src.readlink().find('\n'))
+ throw MergerError("Symlink '" + stringify(src) + "' contains a newline in its target '" +
+ src.readlink() + "', which cannot be stored by VDB");
if (std::string::npos != stringify(src).find(" -> "))
- throw MergerError("'" + stringify(src) + "Symlink ' contains a ' -> ' in its name, which cannot be stored by VDB");
+ throw MergerError("Symlink '" + stringify(src) + "' contains a ' -> ' in its name, which cannot be stored by VDB");
}
Merger::on_sym(is_check, src, dst);
}
diff --git a/paludis/repositories/e/vdb_merger_TEST.cc b/paludis/repositories/e/vdb_merger_TEST.cc
index 88eb657..ac10353 100644
--- a/paludis/repositories/e/vdb_merger_TEST.cc
+++ b/paludis/repositories/e/vdb_merger_TEST.cc
@@ -208,6 +208,16 @@ namespace test_cases
}
} test_vdb_merger_sym_newline;
+ struct VDBMergerTestSymTargetNewline : VDBMergerTest
+ {
+ VDBMergerTestSymTargetNewline() : VDBMergerTest("sym_target_newline") { }
+
+ void run()
+ {
+ TEST_CHECK_THROWS(merger.check(), MergerError);
+ }
+ } test_vdb_merger_sym_target_newline;
+
struct VDBMergerTestSymArrow : VDBMergerTest
{
VDBMergerTestSymArrow() : VDBMergerTest("sym_arrow") { }
diff --git a/paludis/repositories/e/vdb_merger_TEST_setup.sh b/paludis/repositories/e/vdb_merger_TEST_setup.sh
index ea27bfc..f49dfa8 100755
--- a/paludis/repositories/e/vdb_merger_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_merger_TEST_setup.sh
@@ -63,22 +63,26 @@ cd ../..
mkdir -p file_newline_dir/{image,root} || exit 4
touch file_newline_dir/image/"file
-newline"
+newline" || exit 5
mkdir -p dir_newline_dir/{image,root} || exit 4
mkdir dir_newline_dir/image/"dir
-newline"
+newline" || exit 5
mkdir -p sym_newline_dir/{image,root} || exit 4
ln -s foo sym_newline_dir/image/"sym
-newline"
+newline" || exit 5
+
+mkdir -p sym_target_newline_dir/{image,root} || exit 4
+ln -s "foo
+bar" sym_target_newline_dir/image/sym_target_newline || exit 5
mkdir -p sym_arrow_dir/{image,root} || exit 4
-ln -s bar sym_arrow_dir/image/"sym -> arrow"
+ln -s bar sym_arrow_dir/image/"sym -> arrow" || exit 5
mkdir -p sym_arrow2_dir/{image,root} || exit 4
-mkdir sym_arrow2_dir/image/"dir -> ectory"
-ln -s bar sym_arrow2_dir/image/"dir -> ectory/sym"
+mkdir sym_arrow2_dir/image/"dir -> ectory" || exit 5
+ln -s bar sym_arrow2_dir/image/"dir -> ectory/sym" || exit 5
for d in *_dir; do