From a13fb55afdbf9d74c3d4b6aa76476a005da49486 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 11 Sep 2012 17:26:21 -0700 Subject: Add tests and improve param checks Fixed some minor `git_repository_hashfile` issues: - Fixed incorrect doc (saying that repo could be NULL) - Added checking of object type value to acceptable ones - Added more tests for various parameter permutations --- src/odb.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/odb.c') diff --git a/src/odb.c b/src/odb.c index 0d3d809f7..943ffedaa 100644 --- a/src/odb.c +++ b/src/odb.c @@ -117,6 +117,11 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type) git_hash_ctx *ctx; ssize_t read_len; + if (!git_object_typeisloose(type)) { + giterr_set(GITERR_INVALID, "Invalid object type for hash"); + return -1; + } + hdr_len = format_object_header(hdr, sizeof(hdr), size, type); ctx = git_hash_new_ctx(); -- cgit v1.2.1