mirror of https://github.com/omar-polo/gmid.git
don't crash on wrong vhost or missing SNI
the new logging code was crashing if the client didn't support SNI or if required an unknown vhost: this because we short-circuit in handle_handshake to an error, so c->iri isn't populated yet (we don't even read the request). fixes #1
This commit is contained in:
parent
0be51733ef
commit
0ab65593e2
4
gmid.c
4
gmid.c
|
@ -119,6 +119,7 @@ log_request(struct client *c, char *meta, size_t l)
|
|||
if (ec != 0)
|
||||
fatal("getnameinfo: %s", gai_strerror(ec));
|
||||
|
||||
if (c->iri.schema != NULL) {
|
||||
/* serialize the IRI */
|
||||
strlcpy(b, c->iri.schema, sizeof(b));
|
||||
strlcat(b, "://", sizeof(b));
|
||||
|
@ -129,6 +130,9 @@ log_request(struct client *c, char *meta, size_t l)
|
|||
strlcat(b, "?", sizeof(b));
|
||||
strlcat(b, c->iri.query, sizeof(b));
|
||||
}
|
||||
} else {
|
||||
strlcpy(b, c->req, sizeof(b));
|
||||
}
|
||||
|
||||
if ((t = gmid_strnchr(meta, '\r', l)) == NULL)
|
||||
t = meta + len;
|
||||
|
|
5
server.c
5
server.c
|
@ -196,6 +196,11 @@ handle_handshake(struct pollfd *fds, struct client *c)
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue