1
0
forked from aniani/gmnisrv

add a missing "/" to autoindex paths

With the following directory structure:

/srv/gmni:
baz/  foo/

/srv/gmni/baz:
a

/srv/gmni/foo:
bar/

/srv/gmni/foo/bar:
b

trying to access gemini://somesite/ with autoindex=on works,
but accessing /foo fails because it tries to stat /srv/gmni/foobar
instead of /srv/gmni/foo/bar. This commit fixes that by adding a trailing slash.
This commit is contained in:
io mintz 2020-10-13 07:05:10 +00:00 committed by Drew DeVault
parent e77f354ca3
commit a22bec5149

View File

@ -56,8 +56,7 @@ serve_autoindex(struct gmnisrv_client *client, const char *path)
errno = 0;
while ((ent = readdir(dirp)) != NULL) {
char fpath[PATH_MAX + 1];
strcpy(fpath, path);
strncat(fpath, ent->d_name, sizeof(fpath)-1);
snprintf(fpath, sizeof(fpath), "%s/%s", path, ent->d_name);
struct stat st;
if (stat(fpath, &st) != 0) {