NAME_MAX does not account for a terminating NUL
diff --git a/lib/got_lib_object.h b/lib/got_lib_object.h
index 5a1c650..2c568ec 100644
--- a/lib/got_lib_object.h
+++ b/lib/got_lib_object.h
@@ -51,7 +51,7 @@ struct got_commit_object {
struct got_tree_entry {
mode_t mode;
- char name[NAME_MAX];
+ char name[NAME_MAX + 1 /* NUL */];
struct got_object_id id;
int idx;
};
diff --git a/lib/object_create.c b/lib/object_create.c
index cd56ee2..b9728b4 100644
--- a/lib/object_create.c
+++ b/lib/object_create.c
@@ -222,8 +222,8 @@ sort_tree_entries_the_way_git_likes_it(const void *arg1, const void *arg2)
{
struct got_tree_entry * const *te1 = arg1;
struct got_tree_entry * const *te2 = arg2;
- char name1[NAME_MAX + 1];
- char name2[NAME_MAX + 1];
+ char name1[NAME_MAX + 2];
+ char name2[NAME_MAX + 2];
strlcpy(name1, (*te1)->name, sizeof(name1));
strlcpy(name2, (*te2)->name, sizeof(name2));