Subject: Re: [PATCH 2/5] gpg-interface: improve interface for parsing tags

From: "brian m. carlson" <[email-masked]>
Date: Thu, 14 Jan 2021 23:18:23 +0000

On 2021-01-12 at 04:58:57, Junio C Hamano wrote:
> "brian m. carlson" <[email-masked]> writes:
> 
> > diff --git a/ref-filter.c b/ref-filter.c
> > index aa260bfd09..8d8baec1b5 100644
> > --- a/ref-filter.c
> > +++ b/ref-filter.c
> > @@ -1215,7 +1215,13 @@ static void find_subpos(const char *buf,
> >  			unsigned long *nonsiglen,
> >  			const char **sig, unsigned long *siglen)
> >  {
> > +	struct strbuf payload = STRBUF_INIT;
> > +	struct strbuf signature = STRBUF_INIT;
> >  	const char *eol;
> > +	const char *end = buf + strlen(buf);
> > +	const char *sigstart;
> > +
> > +
> >  	/* skip past header until we hit empty line */
> >  	while (*buf && *buf != '\n') {
> >  		eol = strchrnul(buf, '\n');
> > @@ -1228,14 +1234,15 @@ static void find_subpos(const char *buf,
> >  		buf++;
> >  
> >  	/* parse signature first; we might not even have a subject line */
> > -	*sig = buf + parse_signature(buf, strlen(buf));
> > -	*siglen = strlen(*sig);
> > +	parse_signature(buf, end - buf, &payload, &signature);
> > +	*sig = strbuf_detach(&signature, siglen);
> 
> "unsigned long *siglen" may not be the same as "size_t *siglen", and
> the latter is what strbuf_detach() expects to see.  This breaks
> 32-bit builds e.g. [*1*].
> 
> I suspect that all these ${foo}len, including the parameter to this
> function but also the four local variables in its sole caller, would
> want to become size_t.
> 
> Thanks.

I'll reroll with the fixes for size_t and unsigned long.  Feel free to
drop the series if it's causing CI to fail until I get around to that
(likely this weekend).
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US