net-ssh/net-ssh — pull request #48 by martinemde (2012-06-05 22:54:24+00:00)
Title: Fix multibyte strings for UTF-8 encoding in Net::SSH messages.

> Previously, UTF-8 encoded strings would result in the error:
>
> `final': data not multiple of block length (OpenSSL::Cipher::CipherError)
>
> This is because cipher padding length was based on character length
> instead of bytesize. When a UTF-8 character with a bytesize of e.g. 3
> was encountered, Net::SSH would incorrectly add 2 more padding than was
> needed, breaking the block size multiple.
>
> Buffer also incorrectly identified the length of the string in
> write_string using character length instead of bytesize.

I also reported this bug here about 6 months ago:

http://net-ssh.lighthouseapp.com/projects/36253/tickets/48-netssh-fails-with-different-encodings

All tests pass as far as I can tell. In particular you can see how the block size is wrong without the fix (26) and then is correct with the fix (24)