ruby-changes:58061
From: Nobuyoshi <ko1@a...>
Date: Tue, 1 Oct 2019 19:53:51 +0900 (JST)
Subject: [ruby-changes:58061] a0a2640b39 (master): Fix for wrong fnmatch patttern
https://git.ruby-lang.org/ruby.git/commit/?id=a0a2640b39 From a0a2640b398cffd351f87d3f6243103add66575b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 12 Dec 2018 14:38:09 +0900 Subject: Fix for wrong fnmatch patttern * dir.c (file_s_fnmatch): ensure that pattern does not contain a NUL character. https://hackerone.com/reports/449617 diff --git a/dir.c b/dir.c index 6d1f501..d20cf60 100644 --- a/dir.c +++ b/dir.c @@ -3211,7 +3211,7 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj) https://github.com/ruby/ruby/blob/trunk/dir.c#L3211 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 f594a00..16f1076 100644 --- a/test/ruby/test_fnmatch.rb +++ b/test/ruby/test_fnmatch.rb @@ -160,4 +160,10 @@ class TestFnmatch < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fnmatch.rb#L160 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/