upstream patch provided by ruby-core for ruby 2.4.
No CVE numbers, but this fixes the following vulnerabilities:
* Fix a DNS request hijacking vulnerability.
* Fix an ANSI escape sequence vulnerability.
* Fix a DOS vulernerability in the query command.
* Fix a vulnerability in the gem installer that allowed a malicious
gem to overwrite arbitrary files.