Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0c53d2

Browse files
committed
winhttp: Prevent swallowing of url parsing error
1 parent c13b684 commit f0c53d2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/transports/winhttp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,9 +1116,9 @@ static int winhttp_action(
11161116
int ret = -1;
11171117

11181118
if (!t->connection)
1119-
if (gitno_connection_data_from_url(&t->connection_data, url, NULL) < 0 ||
1120-
winhttp_connect(t, url) < 0)
1121-
return -1;
1119+
if ((ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0 ||
1120+
(ret = winhttp_connect(t, url)) < 0)
1121+
return ret;
11221122

11231123
if (winhttp_stream_alloc(t, &s) < 0)
11241124
return -1;

tests/online/clone.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,9 @@ void test_online_clone__ssh_cannot_change_username(void)
463463

464464
cl_git_fail(git_clone(&g_repo, "ssh://[email protected]/libgit2/TestGitRepository", "./foo", &g_options));
465465
}
466+
467+
void test_online_clone__url_with_no_path_returns_EINVALIDSPEC(void)
468+
{
469+
cl_git_fail_with(git_clone(&g_repo, "http://github.com", "./foo", &g_options),
470+
GIT_EINVALIDSPEC);
471+
}

0 commit comments

Comments
 (0)