summaryrefslogtreecommitdiff
path: root/src/tipideed
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-08-29 16:30:15 +0000
committerLaurent Bercot <ska@appnovation.com>2023-08-29 16:30:15 +0000
commit0691bcbd11897694a604f99fa58af6b4286c7195 (patch)
treea5259e0b1118c5d294cb4bfb77fa3d25fed4d121 /src/tipideed
parente6ada0b74352f77124a682d98c6d842fd5c44b45 (diff)
downloadtipidee-0691bcbd11897694a604f99fa58af6b4286c7195.tar.xz
More examples, some fixes, some more doc
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed')
-rw-r--r--src/tipideed/tipideed.c6
1 files changed, 5 insertions, 1 deletions
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) ;