diff --git a/gmid.c b/gmid.c index e9cccf0..510d71f 100644 --- a/gmid.c +++ b/gmid.c @@ -119,15 +119,19 @@ log_request(struct client *c, char *meta, size_t l) if (ec != 0) fatal("getnameinfo: %s", gai_strerror(ec)); - /* serialize the IRI */ - strlcpy(b, c->iri.schema, sizeof(b)); - strlcat(b, "://", sizeof(b)); - strlcat(b, c->iri.host, sizeof(b)); - strlcat(b, "/", sizeof(b)); - strlcat(b, c->iri.path, sizeof(b)); /* TODO: sanitize UTF8 */ - if (*c->iri.query != '\0') { /* TODO: sanitize UTF8 */ - strlcat(b, "?", sizeof(b)); - strlcat(b, c->iri.query, sizeof(b)); + if (c->iri.schema != NULL) { + /* serialize the IRI */ + strlcpy(b, c->iri.schema, sizeof(b)); + strlcat(b, "://", sizeof(b)); + strlcat(b, c->iri.host, sizeof(b)); + strlcat(b, "/", sizeof(b)); + strlcat(b, c->iri.path, sizeof(b)); /* TODO: sanitize UTF8 */ + if (*c->iri.query != '\0') { /* TODO: sanitize UTF8 */ + 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) diff --git a/server.c b/server.c index 728a679..50329cf 100644 --- a/server.c +++ b/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;