Skip to content

Commit

Permalink
Add check for relative path in Local.relative
Browse files Browse the repository at this point in the history
this is to prevent an infinite loop in explode_path
  • Loading branch information
rgrinberg committed May 4, 2018
1 parent cabadcf commit 515b291
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/stdune/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ module Local = struct
| i -> String.sub t ~pos:(i + 1) ~len:(len - i - 1)

let relative ?error_loc t path =
if not (Filename.is_relative path) then (
Exn.code_error "Local.relative: received absolute path"
[ "t", Usexp.atom_or_quoted_string t
; "path", Usexp.atom_or_quoted_string path
]
);
let rec loop t components =
match components with
| [] -> Result.Ok t
Expand Down

0 comments on commit 515b291

Please sign in to comment.