Bug #10988 ยป 0001-Raise-ArgumentError-when-string-passed-to-String-cry.patch
string.c | ||
---|---|---|
}
|
||
s = RSTRING_PTR(str);
|
||
if (!s || memchr(s, '\0', RSTRING_LEN(str)))
|
||
rb_raise(rb_eArgError, "string contains null character");
|
||
if (!s) s = "";
|
||
saltp = RSTRING_PTR(salt);
|
||
if (!saltp[0] || !saltp[1]) goto short_salt;
|
test/ruby/test_string.rb | ||
---|---|---|
assert_raise(ArgumentError) {S("mypassword").crypt(S(""))}
|
||
assert_raise(ArgumentError) {S("mypassword").crypt(S("\0a"))}
|
||
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_32BE, Encoding::UTF_32LE].each do |enc|
|
||
assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
|