diff options
-rw-r--r-- | gmid.h | 2 | ||||
-rw-r--r-- | iri.c | 6 | ||||
-rw-r--r-- | server.c | 6 |
3 files changed, 9 insertions, 5 deletions
@@ -243,7 +243,7 @@ char *utf8_nth(char*, size_t); /* iri.c */ int parse_iri(char*, struct iri*, const char**); -int trim_req_iri(char*); +int trim_req_iri(char*, const char **); /* puny.c */ int puny_decode(const char*, char*, size_t); @@ -364,12 +364,14 @@ parse_iri(char *iri, struct iri *ret, const char **err_ret) } int -trim_req_iri(char *iri) +trim_req_iri(char *iri, const char **err) { char *i; - if ((i = strstr(iri, "\r\n")) == NULL) + if ((i = strstr(iri, "\r\n")) == NULL) { + *err = "missing CRLF"; return 0; + } *i = '\0'; return 1; } @@ -308,8 +308,10 @@ handle_open_conn(struct pollfd *fds, struct client *c) return; } - if (!trim_req_iri(c->req) || !parse_iri(c->req, &c->iri, &parse_err)) { - start_reply(fds, c, BAD_REQUEST, parse_err); + if (!trim_req_iri(c->req, &parse_err) + || !parse_iri(c->req, &c->iri, &parse_err)) { + LOGI(c, "iri parse error: %s", parse_err); + start_reply(fds, c, BAD_REQUEST, "invalid request"); return; } |