Skip to content

Commit ce4208f

Browse files
committed
Fix#315 and resolve relative path vulnerability
1 parent df8dfbc commit ce4208f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎lib/zip/entry.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ def next_header_offset #:nodoc:all
150150
defextract(dest_path=@name, &block)
151151
block ||= proc{ ::Zip.on_exists_proc}
152152

153+
if@name.squeeze('/') =~ /\.{2}(?:\/|\z)/
154+
puts"WARNING: skipped \"../\" path component(s) in #{@name}"
155+
returnself
156+
end
157+
153158
ifdirectory? || file? || symlink?
154159
__send__("create_#{@ftype}",dest_path, &block)
155160
else

0 commit comments

Comments
(0)