]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #1110: sanitize path from plugin
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 18 Jul 2021 22:21:32 +0000 (03:51 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 18 Jul 2021 22:27:53 +0000 (03:57 +0530)
src/nnn.c

index fde07ea5c9cfee579461658409d5e9eb29017da3..5b4f3ad942635feebe3c091ea33b34aaccb44b5b 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5084,7 +5084,12 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
                        return;
 
                g_buf[len] = '\0'; /* Terminate the path read */
-               nextpath = g_buf;
+               if (g_buf[0] == '/') {
+                       nextpath = g_buf;
+                       len = xstrlen(g_buf);
+                       while (--len && (g_buf[len] == '/')) /* Trim all trailing '/' */
+                               g_buf[len] = '\0';
+               }
        } else if (op == 'l') {
                rmlistpath(); /* Remove last list mode path, if any */
                nextpath = load_input(fd, *path);