[MacRuby-devel] [MacRuby] #809: Bus error doing cipher encryption with OpenSSL

MacRuby ruby-noreply at macosforge.org
Thu Jul 22 23:45:19 PDT 2010


#809: Bus error doing cipher encryption with OpenSSL
-------------------------------+--------------------------------------------
 Reporter:  pwilson@…          |       Owner:  lsansonetti@…        
     Type:  defect             |      Status:  new                  
 Priority:  blocker            |   Milestone:  MacRuby 0.7          
Component:  MacRuby            |    Keywords:                       
-------------------------------+--------------------------------------------
 Using the nightly build dated July 21 on Mac OS X 10.6.4, when I try to
 apply a cipher encryption to a string, I get either a bus error or an
 assertion failure, depending on the length of the string.  Here's the
 code:

 {{{
 require 'openssl'

 message1 = "Encrypt me."                     #  Generates assertion
 failure
 message2 = "Encrypt a longer string."        #  Generates bus error

 # Encrypt with 256 bit AES with CBC
 cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
 cipher.encrypt

 # Generate random keys and IVs
 cipher.key = cipher.random_key
 cipher.iv  = cipher.random_iv

 #  Encrypt the data
 encrypted_data = cipher.update(message1)
 encrypted_data << cipher.final
 }}}

 When encrypting the first string (message1), I get this assertion failure:

 {{{
 Assertion failed: (out_len < RSTRING_LEN(str)), function
 ossl_cipher_update, file ossl_cipher.c, line 334.
 }}}

 When encrypting the second string (message2), I get a bus error with this
 stack trace:

 {{{
 Program received signal EXC_BAD_ACCESS, Could not access memory.
 Reason: KERN_PROTECTION_FAILURE at address: 0x0000000100972d60
 0x00007fff844c66d8 in AES_cbc_encrypt ()
 (gdb) bt
 #0  0x00007fff844c66d8 in AES_cbc_encrypt ()
 #1  0x00007fff844cabf3 in aes_256_cbc_cipher ()
 #2  0x00007fff844a64a4 in EVP_EncryptUpdate ()
 #3  0x00007fff844a667f in EVP_CipherUpdate ()
 #4  0x0000000103da8d3a in ossl_cipher_update ()
 #5  0x00000001001409d9 in rb_vm_dispatch ()
 #6  0x0000000103d00950 in ?? ()
 #7  0x0000000103d00220 in ?? ()
 #8  0x000000010014d688 in rb_vm_run ()
 #9  0x00000001000401f0 in ruby_run_node ()
 #10 0x0000000100000d28 in main ()
 }}}

 This code works under both ruby 1.8.7 and ruby 1.9.2(RC1).

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/809>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list