git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] http-push: prevent format overflow warning with gcc >= 9

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
May 14, 2019, 21:11 UTC
Message-ID
<20190514211117.63739-1-carenas@gmail.com>
In function 'finish_request',
    inlined from 'process_response' at http-push.c:248:2:
http-push.c:587:4: warning: '%s' directive argument is null [-Wformat-overflow=]
  587 |    fprintf(stderr, "Unable to get pack file %s\n%s",
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588 |     request->url, curl_errorstr);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

request->url is needed for the error message if there was a failure during fetch but was being cleared unnecessarily earlier.

note that the leak is prevented by calling release_request unconditionally at the end.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Suggested-by: Eric Sunshine <sunshine@sunshineco.com>
---
 http-push.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/http-push.c b/http-push.c
index f675a96316..e36561a6db 100644
--- a/http-push.c
+++ b/http-push.c
@@ -526,8 +526,8 @@ static void finish_request(struct transfer_request *request)
 	if (request->headers != NULL)
 		curl_slist_free_all(request->headers);
 
-	/* URL is reused for MOVE after PUT */
-	if (request->state != RUN_PUT) {
+	/* URL is reused for MOVE after PUT and used during FETCH */
+	if (request->state != RUN_PUT && request->state != RUN_FETCH_PACKED) {
 		FREE_AND_NULL(request->url);
 	}
 
-- 
2.21.0
Message 1 of 1 in “http-push: prevent format overflow warning with gcc >= 9”
  1. http-push: prevent format overflow warning with gcc >= 9Carlo Marcelo Arenas Belón, May 14, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.