Backported fixes to 2.3.18 for CVE-2013-6415 and CVE-2013-6417

These are backports of official patches for [CVE-2013-6415](https://groups.google.com/d/msg/ruby-security-ann/9WiRn2nhfq0/2K2KRB4LwCMJ) and [CVE-2013-6417](https://groups.google.com/d/msg/ruby-security-ann/niK4drpSHT4/g8JW8ZsayRkJ).