Skip to content

Commit b5d2f5e

Browse files
committed
* 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
1 parent 75facde commit b5d2f5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/generators/mod_autoindex.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,8 +1923,13 @@ static int dsortf(struct ent **e1, struct ent **e2)
19231923

19241924
/*
19251925
* First, see if either of the entries is for the parent directory.
1926-
* If so, that *always* sorts lower than anything else.
1926+
* If so, that *always* sorts lower than anything else. The
1927+
* function must be transitive else behaviour is undefined, although
1928+
* in no real case should both entries start with a '/'.
19271929
*/
1930+
if ((*e1)->name[0] == '/' && (*e2)->name[0] == '/') {
1931+
return 0;
1932+
}
19281933
if ((*e1)->name[0] == '/') {
19291934
return -1;
19301935
}

0 commit comments

Comments
 (0)