summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2025-01-08 19:00:29 +0100
committerJoe Orton <jorton@apache.org>2025-01-08 19:00:29 +0100
commitb5d2f5e34e2dde8d1fc0a91f82a3a63737bea1ff (patch)
treeeb11756031d30629a5e8731c80557e4d84587942
parentmod_session_dbd: set_cookie_name: ensure correct format (diff)
downloadapache2-b5d2f5e34e2dde8d1fc0a91f82a3a63737bea1ff.tar.xz
apache2-b5d2f5e34e2dde8d1fc0a91f82a3a63737bea1ff.zip
* 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 <visitorckw gmail.com> Github: closes #500 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1922994 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--modules/generators/mod_autoindex.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c
index 3cafd44b0c..df490a9b3b 100644
--- a/modules/generators/mod_autoindex.c
+++ b/modules/generators/mod_autoindex.c
@@ -1923,8 +1923,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;
}