Commit 1c1b4e8a15b059ae8feb61342de0408755d849ec

Vicent Martí 2013-08-19T02:16:02

Merge pull request #1792 from libgit2/ntk/bug/prefix_size odb: Straighten oid prefix handling

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 76ed8e2..90e2587 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -641,10 +641,12 @@ static int loose_backend__read_prefix(
 {
 	int error = 0;
 
+	assert(len <= GIT_OID_HEXSZ);
+
 	if (len < GIT_OID_MINPREFIXLEN)
 		error = git_odb__error_ambiguous("prefix length too short");
 
-	else if (len >= GIT_OID_HEXSZ) {
+	else if (len == GIT_OID_HEXSZ) {
 		/* We can fall back to regular read method */
 		error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid);
 		if (!error)