Skip to content

Commit edf559f

Browse files
authored
Merge pull request libgit2#6614 from libgit2/ethomson/v1.7
Backports for v1.7
2 parents 3e2baa6 + 393dd49 commit edf559f

File tree

12 files changed

+1180
-181
lines changed

12 files changed

+1180
-181
lines changed

include/git2/sys/transport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define INCLUDE_sys_git_transport_h
1010

1111
#include "git2/net.h"
12+
#include "git2/oidarray.h"
1213
#include "git2/proxy.h"
1314
#include "git2/remote.h"
1415
#include "git2/strarray.h"

src/libgit2/repository.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ int git_repository__cleanup(git_repository *repo)
153153
git_cache_clear(&repo->objects);
154154
git_attr_cache_flush(repo);
155155
git_grafts_free(repo->grafts);
156+
repo->grafts = NULL;
156157
git_grafts_free(repo->shallow_grafts);
158+
repo->shallow_grafts = NULL;
157159

158160
set_config(repo, NULL);
159161
set_index(repo, NULL);

src/libgit2/streams/stransport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static OSStatus write_cb(SSLConnectionRef conn, const void *data, size_t *len)
162162
if (ret < 0) {
163163
st->error = ret;
164164
return (ret == GIT_TIMEOUT) ?
165-
errSSLNetworkTimeout :
165+
-9853 /* errSSLNetworkTimeout */:
166166
-36 /* ioErr */;
167167
}
168168

@@ -214,7 +214,7 @@ static OSStatus read_cb(SSLConnectionRef conn, void *data, size_t *len)
214214
if (ret < 0) {
215215
st->error = ret;
216216
error = (ret == GIT_TIMEOUT) ?
217-
errSSLNetworkTimeout :
217+
-9853 /* errSSLNetworkTimeout */:
218218
-36 /* ioErr */;
219219
break;
220220
} else if (ret == 0) {

src/libgit2/transports/http.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,15 @@ static int lookup_proxy(
335335
}
336336

337337
if (!proxy ||
338-
(error = git_net_url_parse(&transport->proxy.url, proxy)) < 0)
338+
(error = git_net_url_parse_http(&transport->proxy.url, proxy)) < 0)
339339
goto done;
340340

341+
if (!git_net_url_valid(&transport->proxy.url)) {
342+
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy);
343+
error = -1;
344+
goto done;
345+
}
346+
341347
*out_use = true;
342348

343349
done:

src/libgit2/transports/httpclient.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,11 @@ GIT_INLINE(int) server_setup_from_url(
837837
git_http_server *server,
838838
git_net_url *url)
839839
{
840+
GIT_ASSERT_ARG(url);
841+
GIT_ASSERT_ARG(url->scheme);
842+
GIT_ASSERT_ARG(url->host);
843+
GIT_ASSERT_ARG(url->port);
844+
840845
if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) ||
841846
!server->url.host || strcmp(server->url.host, url->host) ||
842847
!server->url.port || strcmp(server->url.port, url->port)) {

src/libgit2/transports/ssh.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,12 @@ static int _git_ssh_setup_conn(
877877
t->current_stream = s;
878878

879879
done:
880+
if (known_hosts)
881+
libssh2_knownhost_free(known_hosts);
882+
880883
if (error < 0) {
881884
ssh_stream_free(*stream);
882885

883-
if (known_hosts)
884-
libssh2_knownhost_free(known_hosts);
885886
if (session)
886887
libssh2_session_free(session);
887888
}

src/libgit2/transports/winhttp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ static int winhttp_stream_connect(winhttp_stream *s)
443443

444444
git_net_url_dispose(&t->proxy.url);
445445

446-
if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
446+
if ((error = git_net_url_parse_http(&t->proxy.url, proxy_url)) < 0)
447447
goto on_error;
448448

449-
if (strcmp(t->proxy.url.scheme, "http") != 0 && strcmp(t->proxy.url.scheme, "https") != 0) {
449+
if (!git_net_url_valid(&t->proxy.url)) {
450450
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy_url);
451451
error = -1;
452452
goto on_error;

0 commit comments

Comments
 (0)