From: Stefan Sperling Subject: Re: fix GOT_IMSG_COMMIT_TRAVERSAL_REQUEST To: Omar Polo Cc: gameoftrees@openbsd.org Date: Sun, 26 Feb 2023 18:23:31 +0100 On Sun, Feb 26, 2023 at 01:02:43PM +0100, Omar Polo wrote: > On 2023/02/26 12:27:36 +0100, Stefan Sperling wrote: > > > There's the weird len > 1 case to handle though, since we're sending a > > > NUL-terminated string. > > > > Can't we change this to avoid sending a trailing '\0' since we already > > know the length? Would that make the code look less surprising? > > Yes, it's more "popular" in privsep.c to do like so and use strndup(3) > on the receiving side. > > While here however I noticed that path can't be empty in practice. > (I'm a bit embarassed for not noticing it before.) > > got_privsep_send_commit_traversal_request would crash on strlen(3) if > path is NULL, and got-read-pack itself assumes `path' is always filled > (being "/" eventually.) > > So, while here, rejects a path of zero too. It's not strictly needed > (`strndup(0)' should work in practice) but it's more explicit about > what we currently require. > > regress with and without GOT_TEST_PACK is still fine :) > > > Thanks, I like this a lot better. ok stsp