Commit bd346313e0947dcef9e789c0ad05d131a80a12bd

Jesse Hathaway 2020-07-10T15:37:08

httpclient: only free challenges for current_server type Prior to this commit we freed both the server and proxy auth challenges in git_http_client_read_response. This works when the proxy needs auth or when the server needs auth, but it does not work when both the proxy and the server need auth as we erroneously remove the server auth challenge before we have added them as server credentials. Instead only remove the challenges for the current_server type. Co-authored-by: Stephen Gelman <ssgelm@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c
index dda2678..7152130 100644
--- a/src/transports/httpclient.c
+++ b/src/transports/httpclient.c
@@ -1374,8 +1374,11 @@ int git_http_client_read_response(
 
 	git_http_response_dispose(response);
 
-	git_vector_free_deep(&client->server.auth_challenges);
-	git_vector_free_deep(&client->proxy.auth_challenges);
+	if (client->current_server == PROXY) {
+		git_vector_free_deep(&client->proxy.auth_challenges);
+	} else if(client->current_server == SERVER) {
+		git_vector_free_deep(&client->server.auth_challenges);
+	}
 
 	client->state = READING_RESPONSE;
 	client->keepalive = 0;