From: Joe Orton Date: Wed, 8 Jan 2025 18:00:29 +0000 (+0000) Subject: * modules/generators/mod_autoindex.c (dsortf): Ensure the function X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5d2f5e34e2dde8d1fc0a91f82a3a63737bea1ff;p=thirdparty%2Fapache%2Fhttpd.git * 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 --- diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 3cafd44b0c6..df490a9b3be 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; }