From 00774b3f92bd6898ce56f41ce39074e9fe89c08e Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 30 Sep 2023 09:38:18 +0000 Subject: Some fixes; new SERVER_NAME source; prepare for more config Signed-off-by: Laurent Bercot --- src/libtipidee/tipidee_rql_read.c | 7 +++---- src/libtipidee/tipidee_uri_parse.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libtipidee') diff --git a/src/libtipidee/tipidee_rql_read.c b/src/libtipidee/tipidee_rql_read.c index f3508cf..fc99f37 100644 --- a/src/libtipidee/tipidee_rql_read.c +++ b/src/libtipidee/tipidee_rql_read.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,7 +9,6 @@ #include #include #include -// #include #include #include @@ -66,12 +66,11 @@ static inline int get_version (char const *in, tipidee_rql *rql) int tipidee_rql_read (buffer *b, char *buf, size_t max, size_t *w, tipidee_rql *rql, tain const *deadline, tain *stamp) { size_t pos[3] = { 0 } ; - if (timed_getlnmax(b, buf, max, &pos[0], '\n', deadline, stamp) <= 0) return -1 ; + if (timed_getlnmax(b, buf, max, &pos[0], '\n', deadline, stamp) == -1) + return errno == ETIMEDOUT ? 99 : -1 ; buf[--pos[0]] = 0 ; if (buf[pos[0] - 1] == '\r') buf[--pos[0]] = 0 ; -// LOLDEBUG("tipidee_rql_read: timed_getlnmax: len is %zu, line is %s", pos[0], buf) ; if (!rql_tokenize(buf, pos)) return 400 ; -// LOLDEBUG("tipidee_rql_read: method: %s, version: %s, uri to parse: %s", buf + pos[0], buf + pos[2], buf + pos[1]) ; rql->m = tipidee_method_tonum(buf + pos[0]) ; if (rql->m == TIPIDEE_METHOD_UNKNOWN) return 400 ; if (!get_version(buf + pos[2], rql)) return 400 ; diff --git a/src/libtipidee/tipidee_uri_parse.c b/src/libtipidee/tipidee_uri_parse.c index 10b0f91..6f0064a 100644 --- a/src/libtipidee/tipidee_uri_parse.c +++ b/src/libtipidee/tipidee_uri_parse.c @@ -154,7 +154,7 @@ size_t tipidee_uri_parse (char *out, size_t max, char const *in, tipidee_uri *ur if (c & 0x4000) host = out + w ; if (c & 0x2000) { if (w >= max) return 0 ; out[w++] = 0 ; } if (c & 0x1000) mark = w ; - if (c & 0x0800) { if (!uint160_scan(out + mark, &port)) return 0 ; w = mark ; } + if (c & 0x0800) { if (!uint160_scan(out + mark, &port) || !port) return 0 ; w = mark ; } if (c & 0x0400) path = out + w ; if (c & 0x0200) { if (w >= max) return 0 ; out[w++] = *in ; } if (c & 0x0100) query = out + w ; -- cgit v1.3.1