* string.c (rb_str_crypt): Raise ArgumentError when
string passed to String#crypt contains null. the patch is from jrusnack <jrusnack at redhat.com>. [Bug #10988] [fix GH-853] * test/ruby/test_string.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d908180164
commit
f64ac5d4cd
@ -1,3 +1,12 @@
|
|||||||
|
Sun May 10 11:44:37 2015 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* string.c (rb_str_crypt): Raise ArgumentError when
|
||||||
|
string passed to String#crypt contains null.
|
||||||
|
the patch is from jrusnack <jrusnack at redhat.com>.
|
||||||
|
[Bug #10988] [fix GH-853]
|
||||||
|
|
||||||
|
* test/ruby/test_string.rb: test for above.
|
||||||
|
|
||||||
Sun May 10 11:23:03 2015 Masaki Matsushita <glass.saga@gmail.com>
|
Sun May 10 11:23:03 2015 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
* enum.c (enum_to_a): Use size to set array capa when possible.
|
* enum.c (enum_to_a): Use size to set array capa when possible.
|
||||||
|
3
string.c
3
string.c
@ -7711,8 +7711,7 @@ rb_str_crypt(VALUE str, VALUE salt)
|
|||||||
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
||||||
}
|
}
|
||||||
|
|
||||||
s = RSTRING_PTR(str);
|
s = StringValueCStr(str);
|
||||||
if (!s) s = "";
|
|
||||||
saltp = RSTRING_PTR(salt);
|
saltp = RSTRING_PTR(salt);
|
||||||
if (!saltp[0] || !saltp[1]) goto short_salt;
|
if (!saltp[0] || !saltp[1]) goto short_salt;
|
||||||
#ifdef BROKEN_CRYPT
|
#ifdef BROKEN_CRYPT
|
||||||
|
@ -507,6 +507,7 @@ class TestString < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError) {S("mypassword").crypt(S(""))}
|
assert_raise(ArgumentError) {S("mypassword").crypt(S(""))}
|
||||||
assert_raise(ArgumentError) {S("mypassword").crypt(S("\0a"))}
|
assert_raise(ArgumentError) {S("mypassword").crypt(S("\0a"))}
|
||||||
assert_raise(ArgumentError) {S("mypassword").crypt(S("a\0"))}
|
assert_raise(ArgumentError) {S("mypassword").crypt(S("a\0"))}
|
||||||
|
assert_raise(ArgumentError) {S("poison\u0000null").crypt(S("aa"))}
|
||||||
[Encoding::UTF_16BE, Encoding::UTF_16LE,
|
[Encoding::UTF_16BE, Encoding::UTF_16LE,
|
||||||
Encoding::UTF_32BE, Encoding::UTF_32LE].each do |enc|
|
Encoding::UTF_32BE, Encoding::UTF_32LE].each do |enc|
|
||||||
assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
|
assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user