* 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/trunk@40925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b5a42f0fa
commit
a0b3e03202
@ -1,3 +1,10 @@
|
|||||||
|
Sat May 25 18:08:06 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.
|
||||||
|
|
||||||
Sat May 25 17:06:25 2013 Koichi Sasada <ko1@atdot.net>
|
Sat May 25 17:06:25 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* gc.c (after_gc_sweep): reduce full GC timing.
|
* gc.c (after_gc_sweep): reduce full GC timing.
|
||||||
|
2
dir.c
2
dir.c
@ -178,7 +178,7 @@ bracket(
|
|||||||
p = t2 + (r2 = rb_enc_mbclen(t2, pend, enc));
|
p = t2 + (r2 = rb_enc_mbclen(t2, pend, enc));
|
||||||
if (ok) continue;
|
if (ok) continue;
|
||||||
if ((r <= (send-s) && memcmp(t1, s, r) == 0) ||
|
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;
|
ok = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -124,4 +124,9 @@ class TestFnmatch < Test::Unit::TestCase
|
|||||||
assert_file.fnmatch("{*,#{pattern_eucjp}}", path, File::FNM_EXTGLOB)
|
assert_file.fnmatch("{*,#{pattern_eucjp}}", path, File::FNM_EXTGLOB)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unicode
|
||||||
|
assert_file.fnmatch("[a-\u3042]*", "\u3042")
|
||||||
|
assert_file.not_fnmatch("[a-\u3042]*", "\u3043")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user