From 0691bcbd11897694a604f99fa58af6b4286c7195 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 29 Aug 2023 16:30:15 +0000 Subject: More examples, some fixes, some more doc Signed-off-by: Laurent Bercot --- src/tipideed/tipideed.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/tipideed/tipideed.c') diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c index 118f33a..f71be9f 100644 --- a/src/tipideed/tipideed.c +++ b/src/tipideed/tipideed.c @@ -30,6 +30,7 @@ #define dieusage() strerr_dieusage(100, USAGE) #define dienomem() strerr_diefu1sys(111, "stralloc_catb") +#define MAX_LOCALREDIRS 32 #define ARGV_MAX 128 struct global_s g = GLOBAL_ZERO ; @@ -367,6 +368,7 @@ int main (int argc, char const *const *argv, char const *const *envp) tipidee_rql rql = TIPIDEE_RQL_ZERO ; tipidee_headers hdr ; int e ; + unsigned int localredirs = 0 ; char const *x ; size_t content_length ; tipidee_transfercoding tcoding = TIPIDEE_TRANSFERCODING_UNKNOWN ; @@ -509,7 +511,9 @@ int main (int argc, char const *const *argv, char const *const *envp) /* And serve the resource. The loop is in case of CGI local-redirection. */ - while (serve(&rql, docroot, hostlen + 1 + g.localportlen, uribuf, &hdr, bodysa.s, bodysa.len)) ; + while (serve(&rql, docroot, hostlen + 1 + g.localportlen, uribuf, &hdr, bodysa.s, bodysa.len)) + if (localredirs++ >= MAX_LOCALREDIRS) + die502x(&rql, 1, "too many local redirections - possible loop involving path ", rql.uri.path) ; } } log_and_exit(0) ; -- cgit v1.2.3