URI: 
       fix realpath when base is a symlink - geomyidae - A small C-based gopherd.
  HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 77f7f5ed8370cf11b8992c70e7f5361625b9afa9
   DIR parent d0a78b16bdbd4330424b9abdcf6448c5a2b42253
  HTML Author: KatolaZ <katolaz@freaknet.org>
       Date:   Sat,  3 Dec 2022 14:18:29 +0000
       
       fix realpath when base is a symlink
       
       Signed-off-by: Christoph Lohmann <20h@r-36.net>
       
       Diffstat:
         M ind.c                               |       9 ++++++---
       
       1 file changed, 6 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/ind.c b/ind.c
       @@ -415,7 +415,7 @@ scanfile(char *fname)
        int
        printelem(int fd, Elems *el, char *file, char *base, char *addr, char *port)
        {
       -        char *path, *p, *argbase, buf[PATH_MAX+1], *argp;
       +        char *path, *p, *argbase, buf[PATH_MAX+1], *argp, *realbase;
                int len, blen;
        
                if (!strcmp(el->e[3], "server")) {
       @@ -461,9 +461,11 @@ printelem(int fd, Elems *el, char *file, char *base, char *addr, char *port)
                        snprintf(buf, sizeof(buf), "%s%.*s/%.*s", base, len,
                                path, blen, el->e[2]);
        
       +                
                        if ((path = realpath(buf, NULL)) &&
       -                                !strncmp(base, path, strlen(base))) {
       -                        p = path + strlen(base);
       +                                (realbase = realpath(base, NULL)) &&
       +                                !strncmp(realbase, path, strlen(realbase))) {
       +                        p = path + strlen(realbase);
        
                                /*
                                 * Do not forget to readd arguments which were
       @@ -476,6 +478,7 @@ printelem(int fd, Elems *el, char *file, char *base, char *addr, char *port)
        
                                free(el->e[2]);
                                el->e[2] = argp;
       +                        free(realbase);
                        }
                        free(path);
                }