From 0758153eec2bb233f26bfb1dbed19d9ac1a2a9ef Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Wed, 9 Apr 2014 12:13:35 +0000 Subject: [PATCH] impl: Strip leading slash from filename if prefix is supplied If prefix is supplied but does not include a trailing slash, then the filename will have a leading slash which will cause int_of_string to fail when trying to interpret the filename as sequence number later. Signed-off-by: Euan Harris --- src/impl.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/impl.ml b/src/impl.ml index bac3c02..d31c426 100644 --- a/src/impl.ml +++ b/src/impl.ml @@ -507,7 +507,8 @@ let serve_tar_to_raw total_size c dest prezeroed progress expected_prefix ignore else let p_len = String.length p in let file_name_len = String.length hdr.Tar.Header.file_name in - return (String.sub hdr.Tar.Header.file_name p_len (file_name_len - p_len)) ) >>= fun filename -> + let filename = String.sub hdr.Tar.Header.file_name p_len (file_name_len - p_len) in + return (Filename.basename filename)) >>= fun filename -> let zero = Cstruct.sub header 0 (Tar.Header.compute_zero_padding_length hdr) in (* either 'counter' or 'counter.checksum' *) if endswith ".checksum" filename then begin