commit 282a1d0a91375cdda585d7c5bf24f61e08623c04 from: Omar Polo date: Tue Mar 16 10:14:24 2021 UTC don't crash on handshake failures ty gemini://discovery.geminiprotocol.com =) commit - a636f50e13c29857f48d1f52db8137dbf7d69660 commit + 282a1d0a91375cdda585d7c5bf24f61e08623c04 blob - cd30080724e0fd247b0e1054a84c0870ca3af214 blob + 6ced0cd6450326897cc443a343a8bb845c833ad1 --- gemini.c +++ gemini.c @@ -234,6 +234,7 @@ do_handshake(int fd, short ev, void *d) { struct req *req = d; const char *hash; + char *e; if (ev == EV_TIMEOUT) { close_with_err(req, "Timeout loading page"); @@ -250,6 +251,13 @@ do_handshake(int fd, short ev, void *d) } hash = tls_peer_cert_hash(req->ctx); + if (hash == NULL) { + if (asprintf(&e, "handshake failed: %s", tls_error(req->ctx)) == -1) + abort(); + close_with_err(req, e); + free(e); + return; + } imsg_compose(ibuf, IMSG_CHECK_CERT, req->id, 0, -1, hash, strlen(hash)+1); imsg_flush(ibuf); }