From d05b3963381a4cd0329bced938d79a23bb392658 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 26 Oct 2023 15:00:30 +0000 Subject: Some more fixes Signed-off-by: Laurent Bercot --- src/include/tipidee/log.h | 2 +- src/libtipidee/tipidee_conf_get_redirection.c | 13 +++++++------ src/tipideed/cgi.c | 4 ++-- src/tipideed/responses.c | 3 +++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/include/tipidee/log.h b/src/include/tipidee/log.h index bf3b812..0904ca4 100644 --- a/src/include/tipidee/log.h +++ b/src/include/tipidee/log.h @@ -22,7 +22,7 @@ #define TIPIDEE_LOG_CLIENTIP 0x0080 #define TIPIDEE_LOG_CLIENTHOST 0x0100 #define TIPIDEE_LOG_HOSTASPREFIX 0x0200 -#define TIPIDEE_LOG_DEBUG 0x0400 +#define TIPIDEE_LOG_DEBUG 0x8000 #define TIPIDEE_LOG_DEFAULT (TIPIDEE_LOG_REQUEST | TIPIDEE_LOG_ANSWER | TIPIDEE_LOG_SIZE) diff --git a/src/libtipidee/tipidee_conf_get_redirection.c b/src/libtipidee/tipidee_conf_get_redirection.c index 9d40de2..b117481 100644 --- a/src/libtipidee/tipidee_conf_get_redirection.c +++ b/src/libtipidee/tipidee_conf_get_redirection.c @@ -11,19 +11,20 @@ static int get_redir (tipidee_conf const *conf, size_t minl, char *key, size_t l, char const *path, tipidee_redirection *r) { - char const *v ; + char const *v = 0 ; key[0] = 'R' ; key[l] = '/' ; - for (;;) + errno = ENOENT ; + while (!v) { - while (l > minl && key[l] != '/') l-- ; - if (l <= minl) return 0 ; + if (errno != ENOENT) return -1 ; + while (l >= minl && key[l] != '/') l-- ; + if (l < minl) break ; key[l--] = 0 ; v = tipidee_conf_get_string(conf, key) ; - if (v) break ; - if (errno != ENOENT) return -1 ; key[0] = 'r' ; } + if (!v) return 0 ; if (v[0] < '@' || v[0] > 'C') return (errno = EPROTO, -1) ; r->type = v[0] & ~'@' ; r->location = v+1 ; diff --git a/src/tipideed/cgi.c b/src/tipideed/cgi.c index 037076d..9751911 100644 --- a/src/tipideed/cgi.c +++ b/src/tipideed/cgi.c @@ -124,10 +124,10 @@ static inline int do_nph (tipidee_rql const *rql, char const *docroot, char cons PROG = progstr ; tain_add_g(&deadline, &g.cgitto) ; close(p[0]) ; - if (ndelay_on(p[1]) == -1) strerr_diefu1sys(111, "set fd nonblocking") ; + if (ndelay_on(p[1]) == -1) die500sys(rql, 111, docroot, "set fd nonblocking") ; if (buffer_timed_put_g(&b, body, bodylen, &deadline) < bodylen || !buffer_timed_flush_g(&b, &deadline)) - strerr_diefu2sys(111, "write request body to nph ", argv[0]) ; + die500sys(rql, 111, docroot, "write request body to nph ", argv[0]) ; _exit(0) ; } default : break ; diff --git a/src/tipideed/responses.c b/src/tipideed/responses.c index 8155b55..f08f83c 100644 --- a/src/tipideed/responses.c +++ b/src/tipideed/responses.c @@ -2,6 +2,7 @@ #include +#include #include #include @@ -103,7 +104,9 @@ void response_error_and_exit (tipidee_rql const *rql, char const *docroot, unsig void response_error_and_die (tipidee_rql const *rql, int e, char const *docroot, unsigned int status, char const *const *v, unsigned int n, uint32_t options) { + int serr = errno ; response_error(rql, docroot, status, options | 1) ; + errno = serr ; if (options & 1) strerr_dievsys(e, v, n) ; else strerr_diev(e, v, n) ; } -- cgit 1.4.1