Merge branch 'jk/upload-pack-bounded-resources'
Various parts of upload-pack has been updated to bound the resource consumption relative to the size of the repository to protect from abusive clients. * jk/upload-pack-bounded-resources: upload-pack: free tree buffers after parsing upload-pack: use PARSE_OBJECT_SKIP_HASH_CHECK in more places upload-pack: always turn off save_commit_buffer upload-pack: disallow object-info capability by default upload-pack: accept only a single packfile-uri line upload-pack: use a strmap for want-ref lines upload-pack: use oidset for deepen_not list upload-pack: switch deepen-not list to an oid_array upload-pack: drop separate v2 "haves" array
This commit is contained in:
14
object.c
14
object.c
@ -271,6 +271,7 @@ struct object *parse_object_with_flags(struct repository *r,
|
||||
enum parse_object_flags flags)
|
||||
{
|
||||
int skip_hash = !!(flags & PARSE_OBJECT_SKIP_HASH_CHECK);
|
||||
int discard_tree = !!(flags & PARSE_OBJECT_DISCARD_TREE);
|
||||
unsigned long size;
|
||||
enum object_type type;
|
||||
int eaten;
|
||||
@ -298,6 +299,17 @@ struct object *parse_object_with_flags(struct repository *r,
|
||||
return lookup_object(r, oid);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the caller does not care about the tree buffer and does not
|
||||
* care about checking the hash, we can simply verify that we
|
||||
* have the on-disk object with the correct type.
|
||||
*/
|
||||
if (skip_hash && discard_tree &&
|
||||
(!obj || obj->type == OBJ_TREE) &&
|
||||
oid_object_info(r, oid, NULL) == OBJ_TREE) {
|
||||
return &lookup_tree(r, oid)->object;
|
||||
}
|
||||
|
||||
buffer = repo_read_object_file(r, oid, &type, &size);
|
||||
if (buffer) {
|
||||
if (!skip_hash &&
|
||||
@ -311,6 +323,8 @@ struct object *parse_object_with_flags(struct repository *r,
|
||||
buffer, &eaten);
|
||||
if (!eaten)
|
||||
free(buffer);
|
||||
if (discard_tree && type == OBJ_TREE)
|
||||
free_tree_buffer((struct tree *)obj);
|
||||
return obj;
|
||||
}
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user