SSLSocket#syswrite no longer raises IOError after IO#close

Aberta
#1,156 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, ruby
Domínio
backend, security

Direção de pesquisa

Start by tracing how SSLSocket#syswrite reaches SSL_write() and how the underlying socket's close is handled, using the reported regression from #1105 as context. Reproduce the supplied UNIXSocket pair example, then add or locate a regression test that checks writing after close raises IOError; the issue names no source or test files, so expect to read around the socket implementation first.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Since bf1a41904e051d31dbb1648019787fe336cec1c8 (#1105), SSLSocket#syswrite no longer raises IOError after IO#close on the underlying socket. SSL_write() still uses the old file descriptor number, so if a new socket gets the same number, the TLS record goes to the new socket.

require "openssl"
require "socket"

key = OpenSSL::PKey::EC.generate("prime256v1")
cert = OpenSSL::X509::Certificate.new
cert.public_key = key
cert.not_before = cert.not_after = Time.now
cert.sign(key, "SHA256")
ctx = OpenSSL::SSL::SSLContext.new
ctx.add_certificate(cert, key)

s1, s2 = UNIXSocket.pair
Thread.new { OpenSSL::SSL::SSLSocket.new(s1, ctx).accept }
ssl = OpenSSL::SSL::SSLSocket.new(s2)
ssl.connect

fd = s2.fileno
s2.close
a, b = UNIXSocket.pair
a.fileno == fd #=> true
ssl.syswrite("hello") #=> 5
b.read_nonblock(100) #=> "\x17\x03\x03\x00\x16..."

I checked the open PRs, but none of them corrects the issue.

Linguagem predominante
C
Estrelas
276
Forks
205
Merge médio
21h 17min
PRs com merge (30d)
17

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ruby/openssl

Todas as issues de ruby/openssl

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.