Check short OID len in odb, not in backends
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/src/odb.c b/src/odb.c
index d49ee30..6f550dd 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -800,7 +800,6 @@ int git_odb_read_prefix(
if (len < GIT_OID_MINPREFIXLEN)
return git_odb__error_ambiguous("prefix length too short");
-
if (len > GIT_OID_HEXSZ)
len = GIT_OID_HEXSZ;
diff --git a/src/odb_loose.c b/src/odb_loose.c
index e0b6ed1..7b46a66 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -647,12 +647,9 @@ static int loose_backend__read_prefix(
{
int error = 0;
- assert(len <= GIT_OID_HEXSZ);
+ assert(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
- if (len < GIT_OID_MINPREFIXLEN)
- error = git_odb__error_ambiguous("prefix length too short");
-
- else if (len == GIT_OID_HEXSZ) {
+ 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)
@@ -698,10 +695,7 @@ static int loose_backend__exists_prefix(
git_buf object_path = GIT_BUF_INIT;
int error;
- assert(backend && out && short_id);
-
- if (len < GIT_OID_MINPREFIXLEN)
- return git_odb__error_ambiguous("prefix length too short");
+ assert(backend && out && short_id && len >= GIT_OID_MINPREFIXLEN);
error = locate_object_short_oid(
&object_path, out, (loose_backend *)backend, short_id, len);