shithub: riscv

Download patch

ref: c3ba64f6935322f09b6de5c2285544fd471c605d
parent: cd5bafe7cbb4736ed53745e288bac44020902f13
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Feb 18 13:54:13 EST 2023

git: fix nil dereference in corrupt repositories

--- a/sys/src/cmd/git/get.c
+++ b/sys/src/cmd/git/get.c
@@ -280,7 +280,7 @@
 		if(hasheq(&have[i], &Zhash) || oshas(&hadobj, have[i]))
 			continue;
 		if((o = readobject(have[i])) == nil)
-			sysfatal("missing object we should have: %H", have[i]);
+			sysfatal("missing exected object: %H", have[i]);
 		if(fmtpkt(c, "have %H", o->hash) == -1)
 			sysfatal("write: %r");
 		enqueueparent(&haveq, o);
--- a/sys/src/cmd/git/ref.c
+++ b/sys/src/cmd/git/ref.c
@@ -126,7 +126,7 @@
 
 	for(i = 0; i < nhead; i++){
 		if((o = readobject(head[i])) == nil){
-			fprint(2, "warning: %H does not point at commit\n", o->hash);
+			fprint(2, "warning: %H does not point at commit\n", head[i]);
 			werrstr("read head %H: %r", head[i]);
 			return -1;
 		}