Re: git log - crash and core dump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



René Scharfe <rene.scharfe@xxxxxxxxxxxxxx> writes:

> Does this patch help?
>
>  pretty.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/pretty.c b/pretty.c
> index d3a82d2..713eefc 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -405,8 +405,8 @@ void pp_user_info(const struct pretty_print_context *pp,
>  	const char *mailbuf, *namebuf;
>  	size_t namelen, maillen;
>  	int max_length = 78; /* per rfc2822 */
> -	unsigned long time;
> -	int tz;
> +	unsigned long time = 0;
> +	int tz = 0;
>  
>  	if (pp->fmt == CMIT_FMT_ONELINE)
>  		return;
> @@ -438,8 +438,10 @@ void pp_user_info(const struct pretty_print_context *pp,
>  	strbuf_add(&name, namebuf, namelen);
>  
>  	namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
> -	time = strtoul(ident.date_begin, &date, 10);
> -	tz = strtol(date, NULL, 10);
> +	if (ident.date_begin) {
> +		time = strtoul(ident.date_begin, &date, 10);
> +		tz = strtol(date, NULL, 10);
> +	}
>  
>  	if (pp->fmt == CMIT_FMT_EMAIL) {
>  		strbuf_addstr(sb, "From: ");

Looks like a sensible change.  split_ident_line() decided that the
given input was mangled and decided there is no valid date (the
input had <> where the timestamp string was required), so the
updated code leaves the time/tz unspecified.

It still is curious how a malformed line was created in the first
place.  I wouldn't worry if a private tool used hash-object to
create such a commit, but if it is something that is commonly used
(e.g. "git commit"), others may suffer from the same and the tool
needs to be tightened a bit.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]