"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: send_zero_refs use GOT_SHA1_STRING_ZERO
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sun, 19 Feb 2023 11:37:11 +0100

Download raw body.

Thread
On Sun, Feb 19, 2023 at 11:01:22AM +0100, Omar Polo wrote:
> simplifies a bit the logic, should be a no-op in practice; ok?

Yes, sure.

> diff /home/op/w/gotsha
> commit - 698a0bd77de9b5498f1dfdf72467b9f739f3db55
> path + /home/op/w/gotsha
> blob - 9f47cd62da86a7219a88652640b642fbcc8aa43b
> file + lib/serve.c
> --- lib/serve.c
> +++ lib/serve.c
> @@ -223,17 +223,11 @@ send_zero_refs(int outfd, int client_is_reading, int c
>  send_zero_refs(int outfd, int client_is_reading, int chattygot)
>  {
>  	const struct got_error *err = NULL;
> +	const char *line = GOT_SHA1_STRING_ZERO " capabilities^{}";
>  	char buf[GOT_PKT_MAX];
> -	uint8_t zero[SHA1_DIGEST_LENGTH];
> -	char hex[SHA1_DIGEST_STRING_LENGTH];
>  	size_t len, capalen = 0;
>  
> -	memset(&zero, 0, sizeof(zero));
> -
> -	if (got_sha1_digest_to_str(zero, hex, sizeof(hex)) == NULL)
> -		return got_error(GOT_ERR_BAD_OBJ_ID);
> -
> -	len = snprintf(buf, sizeof(buf), "%s capabilities^{}", hex);
> +	len = strlcpy(buf, line, sizeof(buf));
>  	if (len >= sizeof(buf))
>  		return got_error(GOT_ERR_NO_SPACE);
>  
> 
>