{"thread":{"id":"52119","subject":"[PATCH 0/1] mingw: avoid a buffer overrun in needs_hiding()","startedAt":"2019-10-25T14:13:40Z","lastAt":"2019-10-25T14:13:42Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"384864","messageId":"pull.427.git.1572012816.gitgitgadget@gmail.com","threadId":"52119","inReplyTo":null,"subject":"[PATCH 0/1] mingw: avoid a buffer overrun in needs_hiding()","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-10-25T14:13:35Z","receivedAt":"2019-10-25T14:13:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"On Unix, files are hidden from the output of ls by default when their names\nstart with a .. On Windows, there is an explicit flag that you need to set.\n\nIt is quite uncommon, though, to hide all of the \"dot files\" on Windows,\nwhich is why Git hides only .git by default, and it has a setting to\noverride this default (core.hideDotFiles).\n\nThe code to determine whether that flag needs to be set for a given file had\na buffer overrun, though, if the path that was passed into the function\nended with a directory separator. This patch fixes this.\n\nThe original contribution by Alex is over at \nhttps://github.com/gitgitgadget/git/pull/414, and I worked with him to\nevolve it into the current version.\n\nCc: Alexandr Miloslavskiy alexandr.miloslavskiy@syntevo.com\n[alexandr.miloslavskiy@syntevo.com]\n\nJohannes Schindelin (1):\n  mingw: avoid a buffer overrun in `needs_hiding()`\n\n compat/mingw.c | 2 ++\n 1 file changed, 2 insertions(+)\n\n\nbase-commit: 566a1439f6f56c2171b8853ddbca0ad3f5098770\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-427%2Fdscho%2Ffix-needs-hiding-buffer-overrun-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-427/dscho/fix-needs-hiding-buffer-overrun-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/427\n-- \ngitgitgadget\n"},{"id":"384865","messageId":"aaf7bfc54572c6a3cd00eb2034c07a7bf57835fe.1572012816.git.gitgitgadget@gmail.com","threadId":"52119","inReplyTo":"pull.427.git.1572012816.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: avoid a buffer overrun in `needs_hiding()`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-10-25T14:13:36Z","receivedAt":"2019-10-25T14:13:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen this function is passed a path with a trailing slash, it runs right\nover the end of that path.\n\nLet's fix this.\n\nCo-authored-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 6b765d936c..fe609239dd 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -363,6 +363,8 @@ static inline int needs_hiding(const char *path)\n \t\t\t/* ignore trailing slashes */\n \t\t\tif (*path)\n \t\t\t\tbasename = path;\n+\t\t\telse\n+\t\t\t\tbreak;\n \t\t}\n \n \tif (hide_dotfiles == HIDE_DOTFILES_TRUE)\n-- \ngitgitgadget\n"}]}