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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: sprinkle some got_object_id over uint8 buffers in gotd
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 9 Jul 2024 21:12:11 +0200

Download raw body.

Thread
On Tue, Jul 09, 2024 at 07:49:50PM +0200, Omar Polo wrote:
> this will make my work for sha256 easier.  (i.e. will let gotd compile
> with other changes I'm doing, pretty sure it will still explode at
> runtime)
> 
> IMHO here it makes sense to pass around an id instead of buffer with the
> hash, if only since it saves some lines ;)
> 
> ok?

Yes, just one remark:

> blob - c21d1c02dd99282f345f37e8dc6e2cb64c1e65b5
> file + gotd/session_write.c
> --- gotd/session_write.c
> +++ gotd/session_write.c
> @@ -523,23 +523,23 @@ forward_notification(struct gotd_session_client *clien
>  		goto done;
>  	}
>  	if (notif->action == GOTD_NOTIF_ACTION_CREATED) {
> -		if (memcmp(notif->new_id.sha1, icontent.new_id,
> -		    SHA1_DIGEST_LENGTH) != 0) {
> +		if (memcmp(&notif->new_id, &icontent.new_id,
> +		    sizeof(notif->new_id)) != 0) {

In the future, we will need to ensure that all struct object_id fields get
initialized even in the (short) sha1 case. Otherwise this comparison of
sizeof() amount of bytes can go wrong.