Skip to contentSkip to conversation

http-push: prevent format overflow warning with gcc >= 9

PATCH New Carlo Marcelo Arenas Belón 1 participant 1 message May 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 http-push: prevent format overflow warning with gcc >= 9

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.

---
 http-push.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
http-push.c +2 -2
index f675a96316..e36561a6db 100644
@@ -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);
 	}
 
Signature · 1 line
2.21.0