nss: tor_tls_release_socket() won't catch invalid socket value
From commit ae569299:
+ tor_socket_t sock =
+ tor_open_socket_nonblocking(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (!sock) {
+ log_warn(LD_NET, "Out of sockets when trying to shut down an NSS "
+ "connection");
+ return;
+ }
A socket value of 0
is a valid socket but not only that, if socket()
did ran out of fd, -1
will be returned (or other errors would send back TOR_INVALID_SOCKET = -1
).
So we probably want if (sock < 0) {}