Closed hhartzer closed 4 months ago
It took me a while but it's very obvious in hindsight.
https://github.com/emikulic/darkhttpd/blob/5031bf1555649df4194cccb1c99d186f8e3f4566/darkhttpd.c#L1891-L1893 When the entries get sorted we check if the first argument of the compare function is "..", but we never check if the second argument is "..".
So ".." was never sorted correctly, the ascii value of ".." is small so it happens to be the first entry most of the time.
I am not sure how to do this best. Adding the check for the second argument would be an easy fix, but I am sure there is a better way.
if (strcmp((*((const struct dlent * const *)b))->name, "..") == 0) {
return 1; /* Special-case ".." to come first. */
}
https://github.com/g-rden/darkhttpd/commit/914c1966f0de3164af77ddaac35cd2ed2919650b This should be better in every way anyway (i hope). Does it matter that the date for ".." is now not listed? It could be added but afaik this is the normal way to display it anyway. For example https://dl-cdn.alpinelinux.org/alpine/
Very nice find! I'm good with that.
I don't mind about the date. :)
Awesome, thank you for fixing this @g-rden!
Still not sure what's going on, but here's a sample directory listing I was able to generate with 1.16 and master.
This doesn't reproduce with just any file with
'
for me.As you can see,
../
is not the first entry like it normally is.