diff options
Diffstat (limited to 'src/libtipidee')
-rw-r--r-- | src/libtipidee/tipidee_rql_read.c | 7 | ||||
-rw-r--r-- | src/libtipidee/tipidee_uri_parse.c | 2 |
2 files changed, 4 insertions, 5 deletions
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 <errno.h> #include <stdint.h> #include <string.h> #include <strings.h> @@ -8,7 +9,6 @@ #include <skalibs/bytestr.h> #include <skalibs/buffer.h> #include <skalibs/unix-timed.h> -// #include <skalibs/lolstdio.h> #include <tipidee/method.h> #include <tipidee/uri.h> @@ -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 ; |