merge revision(s) 40925: [Backport #8451]

* dir.c (bracket): fix copy-paste error.  When the first and last
	  characters of fnmatch range have different length, fnmatch may
	  have wrongly matched a path that does not really match.
	  Coverity Scan found this bug.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-06-04 15:09:53 +00:00
parent 28b7866304
commit 0c91b2493c
4 changed files with 14 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Wed Jun 5 00:08:55 2013 Yusuke Endoh <mame@tsg.ne.jp>
* dir.c (bracket): fix copy-paste error. When the first and last
characters of fnmatch range have different length, fnmatch may
have wrongly matched a path that does not really match.
Coverity Scan found this bug.
Wed Jun 5 00:04:12 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_quote_unprintable): check if argument is a string.

2
dir.c
View file

@ -137,7 +137,7 @@ bracket(
p = t2 + (r2 = rb_enc_mbclen(t2, pend, enc));
if (ok) continue;
if ((r <= (send-s) && memcmp(t1, s, r) == 0) ||
(r2 <= (send-s) && memcmp(t2, s, r) == 0)) {
(r2 <= (send-s) && memcmp(t2, s, r2) == 0)) {
ok = 1;
continue;
}

View file

@ -124,4 +124,9 @@ class TestFnmatch < Test::Unit::TestCase
assert(File.fnmatch("{*,#{pattern_eucjp}}", path, File::FNM_EXTGLOB))
end
end
def test_unicode
assert_file.fnmatch("[a-\u3042]*", "\u3042")
assert_file.not_fnmatch("[a-\u3042]*", "\u3043")
end
end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-06-05"
#define RUBY_PATCHLEVEL 205
#define RUBY_PATCHLEVEL 206
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 6