summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorScott J. Goldman <scottjg@github.com>2012-11-18 15:15:24 -0800
committerScott J. Goldman <scottjg@github.com>2012-11-18 15:15:24 -0800
commit19af78bb36b144022d7dbe68605c8715cd6dc322 (patch)
tree675a68df58298038163f6447f4f64c7e6d5198a2 /src/tree.c
parent629c08293051e9828f2ca3517d2659728647c2cd (diff)
downloadlibgit2-19af78bb36b144022d7dbe68605c8715cd6dc322.tar.gz
Prevent creating `..`, `.`, and `.git` with tree builder
As per core git.
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tree.c b/src/tree.c
index 7b47af347..150f90c44 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -26,7 +26,9 @@ static bool valid_filemode(const int filemode)
static int valid_entry_name(const char *filename)
{
- return *filename != '\0' && strchr(filename, '/') == NULL;
+ return *filename != '\0' && strchr(filename, '/') == NULL &&
+ strcmp(filename, "..") != 0 && strcmp(filename, ".") != 0 &&
+ strcmp(filename, ".git") != 0;
}
static int entry_sort_cmp(const void *a, const void *b)