Commit Diff


commit - 0ab65593e21482c53ece36aa954204d7b202d351
commit + ce79c944bcbc49b1874e6207a0546a4297571dfc
blob - 50329cf18d0e714f84c77f3d01c4e70062019967
blob + f96e0a349e8077d1491a6b78ef484b73c821ffd1
--- server.c
+++ server.c
@@ -180,12 +180,13 @@ handle_handshake(struct pollfd *fds, struct client *c)
 	}
 
 	servname = tls_conn_servername(c->ctx);
-	if (servname == NULL)
-		goto hostnotfound;
 
 	for (h = hosts; h->domain != NULL; ++h) {
-		if (!strcmp(h->domain, servname) || !strcmp(h->domain, "*"))
+		if (!strcmp(h->domain, "*"))
 			break;
+
+		if (servname != NULL && !strcmp(h->domain, servname))
+			break;
 	}
 
 	if (h->domain != NULL) {
@@ -195,13 +196,11 @@ handle_handshake(struct pollfd *fds, struct client *c)
 		return;
 	}
 
-hostnotfound:
 	if (servname != NULL)
 		strncpy(c->req, servname, sizeof(c->req));
 	else
 		strncpy(c->req, "null", sizeof(c->req));
 
-	/* XXX: check the correct response */
 	if (!start_reply(fds, c, BAD_REQUEST, "Wrong host or missing SNI"))
 		return;
 	goodbye(fds, c);