Re: [PATCH] @{-<n>}: avoid crash with corrupt reflog

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

 



Hi,

On Mon, 19 Jan 2009, Johannes Schindelin wrote:

> diff --git a/sha1_name.c b/sha1_name.c
> index 9e5f444..853bac6 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -705,18 +705,18 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
>  	size_t len;
>  	int nth;
>  
> -	if (!prefixcmp(message, "checkout: moving from ")) {
> -		match = message + strlen("checkout: moving from ");
> -		if ((target = strstr(match, " to ")) != NULL)
> -			target += 4;
> -	}
> -
> -	if (!match)
> +	if (prefixcmp(message, "checkout: moving from "))
>  		return 0;
>  
> -	len = target - match - 4;
> -	if (target[len] == '\n' && !strncmp(match, target, len))
> -		return 0;
> +	match = message + strlen("checkout: moving from ");
> +	if ((target = strstr(match, " to ")) != NULL) {
> +		len = target - match - 4;

Aargh, the "- 4" is wrong, of course.

> +		target += 4;
> +		if (target[len] == '\n' && !strncmp(match, target, len))
> +			return 0;
> +	}
> +	else
> +		len = strchrnul(match, ' ') - match;
>  
>  	nth = cb->cnt++ % cb->alloc;
>  	strbuf_reset(&cb->buf[nth]);

Sorry for the noise,
Dscho

--
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]

  Powered by Linux