git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* builtin git-shortlog still broken
@ 2006-12-09  3:23 Nicolas Pitre
  2006-12-09  4:04 ` [PATCH] shortlog: fix segfault on empty authorname Jeff King
  2006-12-09 23:34 ` builtin git-shortlog still broken Johannes Schindelin
  0 siblings, 2 replies; 8+ messages in thread
From: Nicolas Pitre @ 2006-12-09  3:23 UTC (permalink / raw
  To: git; +Cc: Johannes Schindelin

On the Linux kernel repository, doing "git shortlog v2.6.18.." works 
fine. "git shortlog v2.6.17.." works fine. "git shortlog v2.6.16.." also 
works fine.  But "git shortlog v2.6.15.." dies with a segmentation 
fault.  Trying "git log v2.6.15.. | git shortlog" also produces the same 
crash while "git log v2.6.16.. | git shortlog" works fine.

The old perl version doesn't have any such issue with those test cases, 
not even with the whole kernel history.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] shortlog: fix segfault on empty authorname
  2006-12-09  3:23 builtin git-shortlog still broken Nicolas Pitre
@ 2006-12-09  4:04 ` Jeff King
  2006-12-09 21:56   ` Nicolas Pitre
  2006-12-09 23:21   ` Johannes Schindelin
  2006-12-09 23:34 ` builtin git-shortlog still broken Johannes Schindelin
  1 sibling, 2 replies; 8+ messages in thread
From: Jeff King @ 2006-12-09  4:04 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Nicolas Pitre, git, Johannes Schindelin

The old code looked backwards from the email address to parse the name,
allowing an arbitrary number of spaces between the two. However, in the case
of no name, we looked back too far to the 'author' (or 'Author:') header.
Instead, remove at most one space between name and address.

The bug was triggered by commit febf7ea4bed from linux-2.6.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-shortlog.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index f1124e2..7a2ddfe 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -188,7 +188,7 @@ static void read_from_stdin(struct path_list *list)
 				bob = buffer + strlen(buffer);
 			else {
 				offset = 8;
-				while (isspace(bob[-1]))
+				if (isspace(bob[-1]))
 					bob--;
 			}
 
@@ -236,7 +236,7 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list)
 					author = scratch;
 					authorlen = strlen(scratch);
 				} else {
-					while (bracket[-1] == ' ')
+					if (bracket[-1] == ' ')
 						bracket--;
 
 					author = buffer + 7;
-- 
1.4.4.2.g3528-dirty

On Fri, Dec 08, 2006 at 10:23:14PM -0500, Nicolas Pitre wrote:

> On the Linux kernel repository, doing "git shortlog v2.6.18.." works 
> fine. "git shortlog v2.6.17.." works fine. "git shortlog v2.6.16.." also 
> works fine.  But "git shortlog v2.6.15.." dies with a segmentation 
> fault.  Trying "git log v2.6.15.. | git shortlog" also produces the same 
> crash while "git log v2.6.16.. | git shortlog" works fine.
> 
> The old perl version doesn't have any such issue with those test cases, 
> not even with the whole kernel history.
> 
> 
> Nicolas
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] shortlog: fix segfault on empty authorname
  2006-12-09  4:04 ` [PATCH] shortlog: fix segfault on empty authorname Jeff King
@ 2006-12-09 21:56   ` Nicolas Pitre
  2006-12-09 23:21   ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Pitre @ 2006-12-09 21:56 UTC (permalink / raw
  To: Jeff King; +Cc: Junio C Hamano, git, Johannes Schindelin

On Fri, 8 Dec 2006, Jeff King wrote:

> The old code looked backwards from the email address to parse the name,
> allowing an arbitrary number of spaces between the two. However, in the case
> of no name, we looked back too far to the 'author' (or 'Author:') header.
> Instead, remove at most one space between name and address.
> 
> The bug was triggered by commit febf7ea4bed from linux-2.6.
> 
> Signed-off-by: Jeff King <peff@peff.net>

Yep, that fixes the problem.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] shortlog: fix segfault on empty authorname
  2006-12-09  4:04 ` [PATCH] shortlog: fix segfault on empty authorname Jeff King
  2006-12-09 21:56   ` Nicolas Pitre
@ 2006-12-09 23:21   ` Johannes Schindelin
  2006-12-10  3:45     ` Jeff King
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2006-12-09 23:21 UTC (permalink / raw
  To: Jeff King; +Cc: Junio C Hamano, Nicolas Pitre, git

Hi,

On Fri, 8 Dec 2006, Jeff King wrote:

> Instead, remove at most one space between name and address.

Why? We can fix it properly: Instead of

> -				while (isspace(bob[-1]))
> +				if (isspace(bob[-1]))

do something like

				while (bob - 1 != buffer + 7 && 
						isspace(bob[-1]))

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: builtin git-shortlog still broken
  2006-12-09  3:23 builtin git-shortlog still broken Nicolas Pitre
  2006-12-09  4:04 ` [PATCH] shortlog: fix segfault on empty authorname Jeff King
@ 2006-12-09 23:34 ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2006-12-09 23:34 UTC (permalink / raw
  To: Nicolas Pitre; +Cc: git

Hi,

On Fri, 8 Dec 2006, Nicolas Pitre wrote:

> On the Linux kernel repository, doing "git shortlog v2.6.18.." works 
> fine. "git shortlog v2.6.17.." works fine. "git shortlog v2.6.16.." also 
> works fine.  But "git shortlog v2.6.15.." dies with a segmentation 
> fault.  Trying "git log v2.6.15.. | git shortlog" also produces the same 
> crash while "git log v2.6.16.. | git shortlog" works fine.
> 
> The old perl version doesn't have any such issue with those test cases, 
> not even with the whole kernel history.

Yeah, sorry. I assumed that there are enough sanity checks for the author 
format, but evidently that is/was not the case here.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] shortlog: fix segfault on empty authorname
  2006-12-09 23:21   ` Johannes Schindelin
@ 2006-12-10  3:45     ` Jeff King
  2006-12-10  6:01       ` Junio C Hamano
  2006-12-10 22:43       ` Johannes Schindelin
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff King @ 2006-12-10  3:45 UTC (permalink / raw
  To: Johannes Schindelin; +Cc: Junio C Hamano, Nicolas Pitre, git

On Sun, Dec 10, 2006 at 12:21:03AM +0100, Johannes Schindelin wrote:

> > Instead, remove at most one space between name and address.
> 
> Why? We can fix it properly: Instead of
> 
> > -				while (isspace(bob[-1]))
> > +				if (isspace(bob[-1]))
> 
> do something like
> 
> 				while (bob - 1 != buffer + 7 && 
> 						isspace(bob[-1]))

It doesn't look like there are ever extra spaces to get soaked up in the
kernel or git repositories, but if there is a reason to expect
  Full Name    <user@domain>
then we should probably replace my fix with yours.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] shortlog: fix segfault on empty authorname
  2006-12-10  3:45     ` Jeff King
@ 2006-12-10  6:01       ` Junio C Hamano
  2006-12-10 22:43       ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2006-12-10  6:01 UTC (permalink / raw
  To: Jeff King; +Cc: Johannes Schindelin, Nicolas Pitre, git

Jeff King <peff@peff.net> writes:

> It doesn't look like there are ever extra spaces to get soaked up in the
> kernel or git repositories, but if there is a reason to expect
>   Full Name    <user@domain>
> then we should probably replace my fix with yours.

As far as I know, commit-tree removes the extra space if exists,
so your fix would be fine in practice.

People could write crappy replacements of plumbing, and we may
end up with names with trailing whitespaces, but with your fix
at least that would not make us crash, and it may even be
considered a feature -- it would serve as a coalmine canary to
detect such a broken alternative program that creates bogus
commit objects.

We might want to tighten fsck-objects to warn about them,
though.  But that is probably rather low priority.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] shortlog: fix segfault on empty authorname
  2006-12-10  3:45     ` Jeff King
  2006-12-10  6:01       ` Junio C Hamano
@ 2006-12-10 22:43       ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2006-12-10 22:43 UTC (permalink / raw
  To: Jeff King; +Cc: Junio C Hamano, Nicolas Pitre, git

Hi,

On Sat, 9 Dec 2006, Jeff King wrote:

> On Sun, Dec 10, 2006 at 12:21:03AM +0100, Johannes Schindelin wrote:
> 
> > > Instead, remove at most one space between name and address.
> > 
> > Why? We can fix it properly: Instead of
> > 
> > > -				while (isspace(bob[-1]))
> > > +				if (isspace(bob[-1]))
> > 
> > do something like
> > 
> > 				while (bob - 1 != buffer + 7 && 
> > 						isspace(bob[-1]))
> 
> It doesn't look like there are ever extra spaces to get soaked up in the
> kernel or git repositories, but if there is a reason to expect
>   Full Name    <user@domain>
> then we should probably replace my fix with yours.

This is exactly the kind of assumption which led to the bug to begin with.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-12-10 22:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-09  3:23 builtin git-shortlog still broken Nicolas Pitre
2006-12-09  4:04 ` [PATCH] shortlog: fix segfault on empty authorname Jeff King
2006-12-09 21:56   ` Nicolas Pitre
2006-12-09 23:21   ` Johannes Schindelin
2006-12-10  3:45     ` Jeff King
2006-12-10  6:01       ` Junio C Hamano
2006-12-10 22:43       ` Johannes Schindelin
2006-12-09 23:34 ` builtin git-shortlog still broken Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).