Commit Diff


commit - 020c3e5d53e88505ee823e1ac7895d9a604f9a66
commit + e8f51a79078ceac369889d40494e721e7a6027f4
blob - 0d7024446375ed47e5fbc7c9830b2a1d63feee67
blob + ea11d107da95548038e25310c49d564804b1c3d4
--- lib/got_lib_privsep.h
+++ lib/got_lib_privsep.h
@@ -655,8 +655,8 @@ struct got_imsg_patch {
 	int	xbit;
 	char	old[PATH_MAX];
 	char	new[PATH_MAX];
-	char	cid[41];
-	char	blob[41];
+	char	cid[GOT_HASH_DIGEST_STRING_MAXLEN];
+	char	blob[GOT_HASH_DIGEST_STRING_MAXLEN];
 };
 
 /*
blob - 4afb73ee23fb9c7a71b841ff617b0d817f7de341
blob + 931a44be8392e16c83228871c598598f4834bb06
--- lib/patch.c
+++ lib/patch.c
@@ -86,8 +86,8 @@ struct got_patch {
 	int	 xbit;
 	char	*old;
 	char	*new;
-	char	 cid[41];
-	char	 blob[41];
+	char	 cid[GOT_HASH_DIGEST_STRING_MAXLEN];
+	char	 blob[GOT_HASH_DIGEST_STRING_MAXLEN];
 	struct got_patch_hunk_head head;
 };
 
@@ -719,12 +719,14 @@ open_blob(char **path, FILE **fp, const char *blobid,
 	const struct got_error *err = NULL;
 	struct got_blob_object *blob = NULL;
 	struct got_object_id id, *idptr, *matched_id = NULL;
+	enum got_hash_algorithm algo;
 	int fd = -1;
 
 	*fp = NULL;
 	*path = NULL;
+	algo = got_repo_get_object_format(repo);
 
-	if (strlen(blobid) != SHA1_DIGEST_STRING_LENGTH - 1) {
+	if (strlen(blobid) != got_hash_digest_string_length(algo) - 1) {
 		err = got_repo_match_object_id(&matched_id, NULL, blobid,
 		    GOT_OBJ_TYPE_BLOB, NULL /* do not resolve tags */,
 		    repo);
@@ -732,8 +734,7 @@ open_blob(char **path, FILE **fp, const char *blobid,
 			return err;
 		idptr = matched_id;
 	} else {
-		if (!got_parse_object_id(&id, blobid,
-		    got_repo_get_object_format(repo)))
+		if (!got_parse_object_id(&id, blobid, algo))
 			return got_error(GOT_ERR_BAD_OBJ_ID_STR);
 		idptr = &id;
 	}