]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* modules/generators/mod_autoindex.c (dsortf): Ensure the function
authorJoe Orton <jorton@apache.org>
Wed, 8 Jan 2025 18:00:29 +0000 (18:00 +0000)
committerJoe Orton <jorton@apache.org>
Wed, 8 Jan 2025 18:00:29 +0000 (18:00 +0000)
  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

modules/generators/mod_autoindex.c

index 3cafd44b0c6eb9510cd66b91291190db96889d21..df490a9b3be22f3d763c859a845a272bd77f3eaa 100644 (file)
@@ -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;
     }