-
-
Save marshalium/e6bf93b06949890c695d to your computer and use it in GitHub Desktop.
JRuby encode bug examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Here are some base64 encoded sequences of bytes that cause JRuby to hang: | |
7bWdZw== | |
7by/Vg== | |
DO27qA== | |
7bu1Lg== | |
UhbtqbHF04o= | |
bjlSh+2guiM= | |
NOrtppL+zQA= | |
7b27A0BGi5w= | |
4fGnt05Uqe2jqI7RKi664g== | |
7aa4Ne2wUuJb9ozCry1aqw== | |
gzEH7bWg2hvaUVohitrNRA== | |
meXI23O/mZrAX8u27bG3OQ== | |
=end | |
# Here is the script I used to find them. | |
require 'base64' | |
NUM_BYTES = 16 | |
rand = Random.new | |
while true | |
data = rand.bytes(NUM_BYTES) | |
data.force_encoding("UTF-8") | |
puts "data=#{Base64.encode64(data)}" | |
puts "Before calling encode: data.length=#{data.length}" | |
data = data.encode("UTF-16", :undef => :replace, :invalid => :replace, :replace => '') | |
puts "After calling encode: data.length=#{data.length}" | |
puts "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment