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

2 messages, 2 authors, 2021-01-14 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2021-01-12 04:59:50

"brian m. carlson" [off-list ref] writes:
quoted hunk
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.


[Reference]

*1* https://github.com/git/git/runs/1685453231?check_suite_focus=true#step:5:519

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

From: brian m. carlson <hidden>
Date: 2021-01-14 23:19:41

On 2021-01-12 at 04:58:57, Junio C Hamano wrote:
"brian m. carlson" [off-list ref] writes:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help