From: Nobuyoshi Nakada Date: Wed, 12 Dec 2018 05:38:09 +0000 (+0900) Subject: Fix for wrong fnmatch patttern X-Git-Tag: archive/raspbian/2.3.3-1+deb9u7+rpi1^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c324dd977530b484d682dc8cd2f21683a017463c;p=ruby2.3.git Fix for wrong fnmatch patttern * dir.c (file_s_fnmatch): ensure that pattern does not contain a NUL character. https://hackerone.com/reports/449617 Gbp-Pq: Name Fix-for-wrong-fnmatch-patttern.patch --- diff --git a/dir.c b/dir.c index ed72b76..7db7714 100644 --- a/dir.c +++ b/dir.c @@ -2529,7 +2529,7 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj) else flags = 0; - StringValue(pattern); + StringValueCStr(pattern); FilePathStringValue(path); if (flags & FNM_EXTGLOB) { diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb index ca01a28..30250b5 100644 --- a/test/ruby/test_fnmatch.rb +++ b/test/ruby/test_fnmatch.rb @@ -129,4 +129,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