Commit d9e7e1f62a236075d29f003698eaa271a930cc9b

Stefan Sperling 2018-09-19T16:08:32

match tree entries exactly, not by prefix, in find_entry_by_name()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/lib/object.c b/lib/object.c
index b794b8e..77ebb79 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -714,7 +714,8 @@ find_entry_by_name(struct got_tree_object *tree, const char *name, size_t len)
 	struct got_tree_entry *te;
 
 	SIMPLEQ_FOREACH(te, &tree->entries.head, entry) {
-		if (strncmp(te->name, name, len) == 0)
+		if (strlen(te->name) == len &&
+		    strncmp(te->name, name, len) == 0)
 			return te;
 	}
 	return NULL;