]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mingw: avoid a buffer overrun in `needs_hiding()`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 25 Oct 2019 14:13:36 +0000 (14:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Oct 2019 03:38:51 +0000 (12:38 +0900)
When this function is passed a path with a trailing slash, it runs right
over the end of that path.

Let's fix this.

Co-authored-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c

index 738f0a826a51b850fcc93f0cadbf707c7eb0b492..f76ba3d750c806711c2291fabf2d81e18b8ca259 100644 (file)
@@ -363,6 +363,8 @@ static inline int needs_hiding(const char *path)
                        /* ignore trailing slashes */
                        if (*path)
                                basename = path;
                        /* ignore trailing slashes */
                        if (*path)
                                basename = path;
+                       else
+                               break;
                }
 
        if (hide_dotfiles == HIDE_DOTFILES_TRUE)
                }
 
        if (hide_dotfiles == HIDE_DOTFILES_TRUE)