mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix for wrong fnmatch patttern
* dir.c (file_s_fnmatch): ensure that pattern does not contain a NUL character. https://hackerone.com/reports/449617
This commit is contained in:
parent
a38fe1fbf0
commit
a0a2640b39
2 changed files with 7 additions and 1 deletions
2
dir.c
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 @@ class TestFnmatch < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue