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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: do not hardcode digest length when parsing packed trees
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 18 Jul 2024 12:49:53 +0200

Download raw body.

Thread
On 2024/07/17 23:32:33 +0200, Christian Weisgerber <naddy@mips.inka.de> wrote:
> Omar Polo:
> 
> > the subject says it all.  there are a few upcoming diff where I'm
> > replacing SHA1_DIGEST{,_STRING}_LENGTH with the right length derived
> > with got_hash_digest{,_string}_length() but this is a bit more delicate.
> 
> Since you are already in the process of abstracting the hash details,
> I think it would help -portable if all the interfacing with the
> operating system SHA functions were completely encapsulated in
> lib/hash.c, and everything else referenced only got_*() functions
> and GOT_* defines.

Yeah, this is my plan actually.  sha1.h and sha2.h are needed because
some GOT_* defines are in terms of SHA*_DIGEST{,_STRING}_LENGTH but I
see no reason why we couldn't just hardcode the values and get rid of
these includes in the vast majority of the files.

I didn't know it was problematic for -portable to deal with these
includes, so I left the dependency everywhere.  But I'll find a way to
fix it.

> To rephrase, the goal should be to remove
> 
> #include <sha1.h>
> #include <sha2.h>
> 
> from all other source files.

sha2.h should be pretty easy to remove from all the files, just hardcode
the defines in lib/got_lib_hash.h and include/got_object.h.  sha1.h
defines are still used widely in gotd and in the network code, and for
that it'll take me longer "fix".

(the network code needs to implement the git protocol v2, not just bump
the digest length unfortunately.)