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:

> How about making split_ident_line() a bit friendlier be letting it
> provide the epoch as default time stamp instead of NULL?  

Two knee-jerk concerns I have without going back to the callers:

 * Would that "0" ever be given to the approxidate parser, which
   rejects ancient dates in numbers-since-epoch format without @
   prefix?

 * Does any existing caller use the NULL as a sign to see the input
   was without date and act on that information?


> -- >8 --
> Subject: ident: let split_ident_line() provide a default time stamp
>
> If a commit has a broken time stamp, split_ident_line() sets
> date_begin, date_end, tz_begin and tz_end to NULL.  Not all callers
> are prepared to handle that case and segfault.
>
> Instead of fixing them and having to be careful while implementing
> the next caller, provide a string consisting of the number zero as
> default value, representing the UNIX epoch.  That's the value that
> git log showed before it was converted to use split_ident_line().
>
> Reported-by: Ivan Lyapunov <dront78@xxxxxxxxx>
> Signed-off-by: Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx>
> ---
>  ident.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/ident.c b/ident.c
> index 1c123e6..ee840f4 100644
> --- a/ident.c
> +++ b/ident.c
> @@ -191,6 +191,8 @@ static void strbuf_addstr_without_crud(struct strbuf *sb, const char *src)
>  	sb->buf[sb->len] = '\0';
>  }
>  
> +static const char zero_string[] = "0";
> +
>  /*
>   * Reverse of fmt_ident(); given an ident line, split the fields
>   * to allow the caller to parse it.
> @@ -254,10 +256,10 @@ int split_ident_line(struct ident_split *split, const char *line, int len)
>  	return 0;
>  
>  person_only:
> -	split->date_begin = NULL;
> -	split->date_end = NULL;
> -	split->tz_begin = NULL;
> -	split->tz_end = NULL;
> +	split->date_begin = zero_string;
> +	split->date_end = zero_string + strlen(zero_string);
> +	split->tz_begin = zero_string;
> +	split->tz_end = zero_string + strlen(zero_string);
>  	return 0;
>  }
--
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]