Skip to content
Permalink
Browse files

Fix for wrong fnmatch patttern

* dir.c (file_s_fnmatch): ensure that pattern does not contain a
  NUL character.  https://hackerone.com/reports/449617
  • Loading branch information
nobu authored and mame committed Dec 12, 2018
1 parent a38fe1f commit a0a2640b398cffd351f87d3f6243103add66575b
Showing with 7 additions and 1 deletion.
  1. +1 −1 dir.c
  2. +6 −0 test/ruby/test_fnmatch.rb
2 dir.c
@@ -3211,7 +3211,7 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
else
flags = 0;

StringValue(pattern);
StringValueCStr(pattern);
FilePathStringValue(path);

if (flags & FNM_EXTGLOB) {
@@ -160,4 +160,10 @@ def test_unicode
assert_file.fnmatch("[a-\u3042]*", "\u3042")
assert_file.not_fnmatch("[a-\u3042]*", "\u3043")
end

def test_nullchar
assert_raise(ArgumentError) {
File.fnmatch("a\0z", "a")
}
end
end

0 comments on commit a0a2640

Please sign in to comment.
You can’t perform that action at this time.