From 58080f3382cebeadcbbef582e3a1470569e09365 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Fri, 21 Apr 2023 00:08:44 -0400 Subject: [mod_auth] warn if auth.require path never matches warn if auth.require path never matches due to an earlier, shorter path --- src/mod_auth.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mod_auth.c b/src/mod_auth.c index 11cee1e1..d176fdbe 100644 --- a/src/mod_auth.c +++ b/src/mod_auth.c @@ -531,6 +531,18 @@ static handler_t mod_auth_require_parse_array(const array *value, array * const return HANDLER_ERROR; } + for (uint32_t o = 0; o < n; ++o) { + const buffer *k = &((data_array *)value->data[o])->key; + if (buffer_clen(&da_file->key) >= buffer_clen(k) + && 0 == strncmp(da_file->key.ptr, k->ptr, buffer_clen(k))) { + log_error(errh, __FILE__, __LINE__, + "auth.require path (\"%s\") will never match due to " + "earlier match (\"%s\"); fix by sorting longer paths " + "before shorter paths", da_file->key.ptr, k->ptr); + break; + } + } + if (require) { /*(always true at this point)*/ data_auth * const dauth = data_auth_init(); buffer_copy_buffer(&dauth->key, &da_file->key); -- cgit v1.2.1