conmon icon indicating copy to clipboard operation
conmon copied to clipboard

conn_sock.c audit

Open mtrmac opened this issue 6 months ago • 0 comments

If someone were very bored… conn_sock.c could use an overhaul.

  • There are basically 5 distinct kinds of file descriptors (console/notify source, stream/notify destination, listener), modeled as 2 structs + enums.
  • The code assumes, but does not structurally promise — or even document — that console/stream goes together (look at the opt_stdin special case)
  • AFAICS remote_sock_shutdown can close a file descriptor while a remote_sock_cb is still pending
  • if (num_read < 0) return G_SOURCE_CONTINUE; looks suspicious

I’m not at all saying any of these things matter in production.

I also rather strongly suspect that refactoring this with confidence requires tooling support. I.e. it is… both dependent on, and a prerequisite of :), moving to something like Rust.

mtrmac avatar Aug 13 '25 02:08 mtrmac