aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmid.h2
-rw-r--r--iri.c6
-rw-r--r--server.c6
3 files changed, 9 insertions, 5 deletions
diff --git a/gmid.h b/gmid.h
index 862792f..f11ffbb 100644
--- a/gmid.h
+++ b/gmid.h
@@ -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);
diff --git a/iri.c b/iri.c
index beba368..f7cb627 100644
--- a/iri.c
+++ b/iri.c
@@ -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;
}
diff --git a/server.c b/server.c
index 1383974..d0e5e4b 100644
--- a/server.c
+++ b/server.c
@@ -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;
}