Issue #7312 has been updated by vo.x (Vit Ondruch).


=begin
This is reduced test case:

  def test_str_crypt
    str = ""
    salt = e("\xa1\xa1")

    if a(salt).length < 2
      assert_raise(ArgumentError) { str.crypt(salt) }
    end

    t = str.crypt(salt)
    assert_equal(a(str).crypt(a(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
    assert_encoding('ASCII-8BIT', t.encoding)
  end

And GDB session:

 6916	    StringValue(salt);
 (gdb) 
 6917	    if (RSTRING_LEN(salt) < 2)
 (gdb) 
 6920	    s = RSTRING_PTR(str);
 (gdb) 
 6922	    saltp = RSTRING_PTR(salt);
 (gdb) 
 6931	    result = rb_str_new2(crypt(s, saltp));
 (gdb) s
 rb_str_new_cstr (ptr=0x0) at string.c:435
 435	    if (!ptr) {
 
So the crypt(3) definitely returns NULL for e("\xa1\xa1").

BTW this is my glibc version:

 $ rpm -q glibc
 glibc-2.16.90-28.fc19.x86_64
 
And this [1] might be the offending patch, particularly the crypt/crypt-entry.c change? It seems that they are now stricter what might be salt now.

[1] ((<URL:http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=4ba74a357376c8f8bf49487f96ae71cf2460c3f3>))
=end

----------------------------------------
Bug #7312: test_str_crypt(TestM17NComb) fails
https://bugs.ruby-lang.org/issues/7312#change-32707

Author: vo.x (Vit Ondruch)
Status: Feedback
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: 
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-08 trunk 37564) [x86_64-linux]


=begin
 test_str_crypt(TestM17NComb):
 ArgumentError: NULL pointer given
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/test_m17n_comb.rb:728:in `crypt'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/test_m17n_comb.rb:728:in `block in test_str_crypt'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:83:in `block in each'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:75:in `block in each_index'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:46:in `block in make_large_block'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:26:in `block (2 levels) in make_basic_block'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:21:in `times'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:21:in `block in make_basic_block'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:20:in `times'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:20:in `make_basic_block'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:45:in `make_large_block'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:71:in `each_index'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/allpairs.rb:82:in `each'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/test_m17n_comb.rb:60:in `combination'
     /builddir/build/BUILD/ruby-2.0.0-r37564/test/ruby/test_m17n_comb.rb:723:in `test_str_crypt'
=end



-- 
http://bugs.ruby-lang.org/