shithub: git9

Download patch

ref: 7e8b355535c10bd7db3bd0d7085286c555fd3497
parent: f444579d88c3f1a26649dd125ea6e03862e67912
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Feb 23 17:05:27 EST 2021

packfiles: be more paranoid about object types

More places that tags pointing at non-commits can
make us unhappy.

--- a/pack.c
+++ b/pack.c
@@ -1323,6 +1323,11 @@
 		return 0;
 	if((t = readobject(tree)) == nil)
 		return -1;
+	if(c->type != GTree){
+		fprint(2, "load: %H: not tree\n", c->hash);
+		unref(c);
+		return -1;
+	}
 	addmeta(v, has, t, dpath, mtime);
 	for(i = 0; i < t->tree->nent; i++){
 		e = &t->tree->ent[i];
@@ -1355,6 +1360,11 @@
 		return 0;
 	if((c = readobject(h)) == nil)
 		return -1;
+	if(c->type != GCommit){
+		fprint(2, "load: %H: not commit\n", c->hash);
+		unref(c);
+		return -1;
+	}
 	addmeta(v, has, c, "", c->commit->ctime);
 	r = loadtree(v, has, c->commit->tree, "", c->commit->ctime);
 	unref(c);