From f01f2cc3fa2dd4bea4b07aac8a948d960a02f37f Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Wed, 8 Jan 2025 18:00:29 +0000 Subject: [PATCH 1/3] * modules/generators/mod_autoindex.c (dsortf): Ensure the function is transitive to avoid undefined behaviour, per: https://www.qualys.com/2024/01/30/qsort.txt Submitted by: Kuan-Wei Chiu Github: closes #500 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1922994 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit b5d2f5e34e2dde8d1fc0a91f82a3a63737bea1ff) --- modules/generators/mod_autoindex.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 715b49c7d74..45a285e134a 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -1915,8 +1915,13 @@ static int dsortf(struct ent **e1, struct ent **e2) /* * First, see if either of the entries is for the parent directory. - * If so, that *always* sorts lower than anything else. + * If so, that *always* sorts lower than anything else. The + * function must be transitive else behaviour is undefined, although + * in no real case should both entries start with a '/'. */ + if ((*e1)->name[0] == '/' && (*e2)->name[0] == '/') { + return 0; + } if ((*e1)->name[0] == '/') { return -1; } From d757ba29b969de99e258a6253a81733d6b0cc4d4 Mon Sep 17 00:00:00 2001 From: Giovanni Bechis Date: Wed, 21 Jan 2026 08:57:27 +0000 Subject: [PATCH 2/3] add charset in the document if specified in IndexOptions bz #69930 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1931451 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 6ab19469cc43b3dc75e4b041d6a199822655c00f) --- modules/generators/mod_autoindex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 45a285e134a..dc102a42cb8 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -176,7 +176,11 @@ static void emit_preamble(request_rec *r, int xhtml, const char *title) if (xhtml) { ap_rvputs(r, DOCTYPE_XHTML_1_0T, "\n" - " \n Index of ", title, + " <head>\n", NULL); + if(d->charset != NULL) { + ap_rvputs(r, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=", d->charset, "\" />\n", NULL); + } + ap_rvputs(r, " <title>Index of ", title, "\n", NULL); } else { ap_rvputs(r, DOCTYPE_HTML_4_01, From 048003d328c9d66110bfb879cd212a91a4e40862 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 5 Jun 2026 09:45:07 +0000 Subject: [PATCH 3/3] * modules/generators/mod_autoindex.c (add_header): Reject invalid NameWidth values less than 5, including zero. Submitted by: metsw24-max GitHub: closes #617 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1935002 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 83091c327b41c18aa1eea36f294d95e9f38bd9b8) --- modules/generators/mod_autoindex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index dc102a42cb8..c6dba8fc34b 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -461,8 +461,8 @@ static const char *add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[ else { int width = atoi(&w[10]); - if (width && (width < 5)) { - return "NameWidth value must be greater than 5"; + if (width < 5) { + return "NameWidth value must be at least 5"; } d_cfg->name_width = width; d_cfg->name_adjust = K_NOADJUST;