Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ users)
## Actions
* Reorder the list of actions by increased priority [#6864 @kit-ty-kate - fix #6863]
* The internal `sources` directory now only serves to cache dev packages instead of every packages, saving disk space. For other packages it is now removed during the build phase. [#6440 @kit-ty-kate - fix #4056 #5448]
* Stop the installation process via .install file from creating unnecessary intermediate directories for paths that contain `..` [#7015 @kit-ty-kate]

## Install
* Remove the build directory as soon as possible when installing a package [#6906 @kit-ty-kate - fix #5884]
Expand Down Expand Up @@ -237,6 +238,7 @@ users)
* Add a test showing when opam creates a local switch vs. global [#6981 @kit-ty-kate]
* Add a test showing the behaviour of `opam lock` in presence of disjunction in the dependency formula [#6990 @kit-ty-kate]
* Add a test showing the behaviour of `opam pin add <url to archive>` [#7012 @kit-ty-kate]
* Add more tests to ensure the inescapability of relative paths containing `..` in .install files [#7015 @kit-ty-kate]

### Engine
* Add `http-server` to launch a minimal http server [#6939 @rjbou]
Expand Down
18 changes: 9 additions & 9 deletions src/client/opamAction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,33 @@ let preprocess_dot_install_t st nv build_dir =
else
(base, false) in
let src_file = OpamFilename.create build_dir base.c in
let dst_file = match dst with
let unsafe_dst_file = match dst with
| None -> OpamFilename.create dst_dir (OpamFilename.basename src_file)
| Some d ->
if append && not (OpamFilename.Base.check_suffix d ".exe") then
OpamFilename.create dst_dir
(OpamFilename.Base.add_extension d "exe")
else
OpamFilename.create dst_dir d in
let dst_file =
OpamFilename.of_string
(OpamSystem.real_path (OpamFilename.to_string unsafe_dst_file))
in
let file = file_wo_prefix dst_file in
let inst warning =
if append then warning (OpamFilename.to_string src_file) `Add_exe;
let check, warn = check ~src:build_dir ~dst:dst_dir base in
let real_dst =
OpamFilename.of_string
(OpamSystem.real_path (OpamFilename.to_string dst_file))
in
let escapes =
not (OpamFilename.starts_with switch_prefix real_dst)
|| (OpamFilename.starts_with switch_meta real_dst)
not (OpamFilename.starts_with switch_prefix dst_file)
|| (OpamFilename.starts_with switch_meta dst_file)
in
if escapes then
(OpamConsole.error
"package %s attempted to install a file outside allowed \
destination directories: %s -> %s."
(OpamPackage.Name.to_string name)
(OpamFilename.to_string dst_file)
(OpamFilename.to_string real_dst);
(OpamFilename.to_string unsafe_dst_file)
(OpamFilename.to_string dst_file);
failwith ".install file escaping allowed directories")
else if check then
OpamFilename.install ~warning ~exec ~src:src_file ~dst:dst_file ();
Expand Down
Loading
Loading