Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1756843293, "reponame":"openssl", "desc":"OpenSSL", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/openssl", "f":3, "items": [ {"schema":"libjg2-1", "cid":"2773696a0ec2b1cb17449420e967b30f", "commit": {"type":"commit", "time": 1447453038, "time_ofs": 18446744073709551316, "oid_tree": { "oid": "77c7d5fd9075dc8239791f6e26707e9974dab703", "alias": []}, "oid":{ "oid": "cfb4f1efbae561e7b70bf97fc8973b2aa084cb14", "alias": []}, "msg": "RT2667: Add IRC support to -starttls", "sig_commit": { "git_time": { "time": 1447453038, "offset": -300 }, "name": "Rich Salz", "email": "rsalz@openssl.org", "md5": "3ed6b9cf7bbe83902a044f6590346d26" }, "sig_author": { "git_time": { "time": 1431547221, "offset": -240 }, "name": "Nathan Phillip Brink", "email": "ohnobinki@ohnopublishing.net", "md5": "a8defe14b1c80bc2bd59a1fab3848cfb" }}, "body": "RT2667: Add IRC support to -starttls\n\nReviewed-by: Tim Hudson \u003ctjh@openssl.org\u003e\n" , "diff": "diff --git a/apps/s_client.c b/apps/s_client.c\nindex fc0174f..94f2a94 100644\n--- a/apps/s_client.c\n+++ b/apps/s_client.c\n@@ -175,6 +175,7 @@ typedef unsigned int u_int;\n \n #undef BUFSIZZ\n #define BUFSIZZ 1024*8\n+#define S_CLIENT_IRC_READ_TIMEOUT 8\n \n extern int verify_depth;\n extern int verify_error;\n@@ -516,7 +517,7 @@ OPTIONS s_client_options[] \u003d {\n {\u0022tls1_1\u0022, OPT_TLS1_1, '-', \u0022Just use TLSv1.1\u0022},\n {\u0022tls1\u0022, OPT_TLS1, '-', \u0022Just use TLSv1\u0022},\n {\u0022starttls\u0022, OPT_STARTTLS, 's',\n- \u0022Use the STARTTLS command before starting TLS\u0022},\n+ \u0022Use the appropriate STARTTLS command before starting TLS\u0022},\n {\u0022xmpphost\u0022, OPT_XMPPHOST, 's',\n \u0022Host to use with \u005c\u0022-starttls xmpp[-server]\u005c\u0022\u0022},\n {\u0022rand\u0022, OPT_RAND, 's',\n@@ -614,7 +615,8 @@ typedef enum PROTOCOL_choice {\n PROTO_TELNET,\n PROTO_XMPP,\n PROTO_XMPP_SERVER,\n- PROTO_CONNECT\n+ PROTO_CONNECT,\n+ PROTO_IRC\n } PROTOCOL_CHOICE;\n \n static OPT_PAIR services[] \u003d {\n@@ -625,6 +627,7 @@ static OPT_PAIR services[] \u003d {\n {\u0022xmpp\u0022, PROTO_XMPP},\n {\u0022xmpp-server\u0022, PROTO_XMPP_SERVER},\n {\u0022telnet\u0022, PROTO_TELNET},\n+ {\u0022irc\u0022, PROTO_IRC},\n {NULL}\n };\n \n@@ -1644,6 +1647,67 @@ int s_client_main(int argc, char **argv)\n }\n }\n break;\n+ case PROTO_IRC:\n+ {\n+ int numeric;\n+ BIO *fbio \u003d BIO_new(BIO_f_buffer());\n+\n+ BIO_push(fbio, sbio);\n+ BIO_printf(fbio, \u0022STARTTLS\u005cr\u005cn\u0022);\n+ (void)BIO_flush(fbio);\n+ width \u003d SSL_get_fd(con) + 1;\n+\n+ do {\n+ numeric \u003d 0;\n+\n+ FD_ZERO(\u0026readfds);\n+ openssl_fdset(SSL_get_fd(con), \u0026readfds);\n+ timeout.tv_sec \u003d S_CLIENT_IRC_READ_TIMEOUT;\n+ timeout.tv_usec \u003d 0;\n+ /*\n+ * If the IRCd doesn't respond within\n+ * S_CLIENT_IRC_READ_TIMEOUT seconds, assume\n+ * it doesn't support STARTTLS. Many IRCds\n+ * will not give _any_ sort of response to a\n+ * STARTTLS command when it's not supported.\n+ */\n+ if (!BIO_get_buffer_num_lines(fbio)\n+ \u0026\u0026 !BIO_pending(fbio)\n+ \u0026\u0026 !BIO_pending(sbio)\n+ \u0026\u0026 select(width, (void *)\u0026readfds, NULL, NULL,\n+ \u0026timeout) \u003c 1) {\n+ BIO_printf(bio_err,\n+ \u0022Timeout waiting for response (%d seconds).\u005cn\u0022,\n+ S_CLIENT_IRC_READ_TIMEOUT);\n+ break;\n+ }\n+\n+ mbuf_len \u003d BIO_gets(fbio, mbuf, BUFSIZZ);\n+ if (mbuf_len \u003c 1 || sscanf(mbuf, \u0022%*s %d\u0022, \u0026numeric) !\u003d 1)\n+ break;\n+ /* :example.net 451 STARTTLS :You have not registered */\n+ /* :example.net 421 STARTTLS :Unknown command */\n+ if ((numeric \u003d\u003d 451 || numeric \u003d\u003d 421)\n+ \u0026\u0026 strstr(mbuf, \u0022STARTTLS\u0022) !\u003d NULL) {\n+ BIO_printf(bio_err, \u0022STARTTLS not supported: %s\u0022, mbuf);\n+ break;\n+ }\n+ if (numeric \u003d\u003d 691) {\n+ BIO_printf(bio_err, \u0022STARTTLS negotiation failed: \u0022);\n+ ERR_print_errors(bio_err);\n+ break;\n+ }\n+ } while (numeric !\u003d 670);\n+\n+ (void)BIO_flush(fbio);\n+ BIO_pop(fbio);\n+ BIO_free(fbio);\n+ if (numeric !\u003d 670) {\n+ BIO_printf(bio_err, \u0022Server does not support STARTTLS.\u005cn\u0022);\n+ ret \u003d 1;\n+ goto shut;\n+ }\n+ }\n }\n \n for (;;) {\ndiff --git a/doc/apps/s_client.pod b/doc/apps/s_client.pod\nindex 4d23dc9..6468999 100644\n--- a/doc/apps/s_client.pod\n+++ b/doc/apps/s_client.pod\n@@ -298,8 +298,8 @@ command for more information.\n \n send the protocol-specific message(s) to switch to TLS for communication.\n B\u003cprotocol\u003e is a keyword for the intended protocol. Currently, the only\n-supported keywords are \u0022smtp\u0022, \u0022pop3\u0022, \u0022imap\u0022, \u0022ftp\u0022, \u0022xmpp\u0022,\n-and \u0022xmpp-server\u0022.\n+supported keywords are \u0022smtp\u0022, \u0022pop3\u0022, \u0022imap\u0022, \u0022ftp\u0022, \u0022xmpp\u0022, \u0022xmpp-server\u0022,\n+and \u0022irc.\u0022\n \n \u003ditem B\u003c-xmpphost hostname\u003e\n \n","s":{"c":1756843293,"u": 8188}} ],"g": 9381,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}