Commit 26875825 by Russell Belfer

Check short OID len in odb, not in backends

parent 13f7ecd7
...@@ -800,7 +800,6 @@ int git_odb_read_prefix( ...@@ -800,7 +800,6 @@ int git_odb_read_prefix(
if (len < GIT_OID_MINPREFIXLEN) if (len < GIT_OID_MINPREFIXLEN)
return git_odb__error_ambiguous("prefix length too short"); return git_odb__error_ambiguous("prefix length too short");
if (len > GIT_OID_HEXSZ) if (len > GIT_OID_HEXSZ)
len = GIT_OID_HEXSZ; len = GIT_OID_HEXSZ;
......
...@@ -647,12 +647,9 @@ static int loose_backend__read_prefix( ...@@ -647,12 +647,9 @@ static int loose_backend__read_prefix(
{ {
int error = 0; int error = 0;
assert(len <= GIT_OID_HEXSZ); assert(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
if (len < GIT_OID_MINPREFIXLEN) if (len == GIT_OID_HEXSZ) {
error = git_odb__error_ambiguous("prefix length too short");
else if (len == GIT_OID_HEXSZ) {
/* We can fall back to regular read method */ /* We can fall back to regular read method */
error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid); error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid);
if (!error) if (!error)
...@@ -698,10 +695,7 @@ static int loose_backend__exists_prefix( ...@@ -698,10 +695,7 @@ static int loose_backend__exists_prefix(
git_buf object_path = GIT_BUF_INIT; git_buf object_path = GIT_BUF_INIT;
int error; int error;
assert(backend && out && short_id); assert(backend && out && short_id && len >= GIT_OID_MINPREFIXLEN);
if (len < GIT_OID_MINPREFIXLEN)
return git_odb__error_ambiguous("prefix length too short");
error = locate_object_short_oid( error = locate_object_short_oid(
&object_path, out, (loose_backend *)backend, short_id, len); &object_path, out, (loose_backend *)backend, short_id, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment