1
0
mirror of https://git.sr.ht/~sircmpwn/gmnisrv synced 2024-11-03 06:07:17 -05:00

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; errno = 0;
while ((ent = readdir(dirp)) != NULL) { while ((ent = readdir(dirp)) != NULL) {
char fpath[PATH_MAX + 1]; char fpath[PATH_MAX + 1];
strcpy(fpath, path); snprintf(fpath, sizeof(fpath), "%s/%s", path, ent->d_name);
strncat(fpath, ent->d_name, sizeof(fpath)-1);
struct stat st; struct stat st;
if (stat(fpath, &st) != 0) { if (stat(fpath, &st) != 0) {