git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "git fmt-merge-msg" SIGSEGV
@ 2006-11-17  6:57 Linus Torvalds
  0 siblings, 0 replies; only message in thread
From: Linus Torvalds @ 2006-11-17  6:57 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


Ok, this is a _really_ stupid case, and I don't think it matters, but hey, 
we should never SIGSEGV.

Steps to reproduce:

	mkdir duh
	cd duh
	git init-db
	git-fmt-merge-msg < /dev/null

will cause a SIGSEGV in cmd_fmt_merge_msg(), because we're doing a 
strncmp() with a NULL current_branch.

And yeah, it's an insane schenario, and no, it doesn't really matter. The 
only reason I noticed was that a broken version of my "git pull" into an 
empty directory would cause this.

This silly patch just replaces the SIGSEGV with a controlled exit with an 
error message.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 3d3097d..87d3d63 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -278,6 +278,8 @@ int cmd_fmt_merge_msg(int argc, const ch
 
 	/* get current branch */
 	current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
+	if (!current_branch)
+		die("No current branch");
 	if (!strncmp(current_branch, "refs/heads/", 11))
 		current_branch += 11;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2006-11-17  6:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-17  6:57 "git fmt-merge-msg" SIGSEGV Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).