SSLSocket#syswrite no longer raises IOError after IO#close

Aperta
#1,156 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, ruby
Ambito
backend, security

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C
Stelle
276
Fork
205
Merge medio
21h 17m
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ruby/openssl

Tutte le issue di ruby/openssl

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.