8000 Merge pull request #6511 from libgit2/ethomson/hostandport · libgit2/libgit2@c0dc97b · GitHub
[go: up one dir, main page]

Skip to content

Commit c0dc97b

Browse files
authored
Merge pull request #6511 from libgit2/ethomson/hostandport
Revert #6503
2 parents 44d3372 + c28ebdf commit c0dc97b

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/libgit2/transports/ssh.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ static int check_against_known_hosts(
651651
return ret;
652652
}
653653

654-
#define SSH_DEFAULT_PORT 22
655-
656654
/*
657655
* Perform the check for the session's certificate against known hosts if
658656
* possible and then ask the user if they have a callback.
@@ -750,29 +748,23 @@ static int check_certificate(
750748
if (check_cb != NULL) {
751749
git_cert_hostkey *cert_ptr = &cert;
752750
git_error_state previous_error = {0};
753-
const char *host_ptr = host;
754-
git_str host_and_port = GIT_STR_INIT;
755-
756-
if (port != SSH_DEFAULT_PORT) {
757-
git_str_printf(&host_and_port, "%s:%d", host, port);
758-
host_ptr = host_and_port.ptr;
759-
}
760751

761752
git_error_state_capture(&previous_error, error);
762-
error = check_cb((git_cert *) cert_ptr, cert_valid, host_ptr, check_cb_payload);
753+
error = check_cb((git_cert *) cert_ptr, cert_valid, host, check_cb_payload);
763754
if (error == GIT_PASSTHROUGH) {
764755
error = git_error_state_restore(&previous_error);
765756
} else if (error < 0 && !git_error_last()) {
766757
git_error_set(GIT_ERROR_NET, "unknown remote host key");
767758
}
768759

769760
git_error_state_free(&previous_error);
770-
git_str_dispose(&host_and_port);
771761
}
772762

773763
return error;
774764
}
775765

766+
#define SSH_DEFAULT_PORT "22"
767+
776768
static int _git_ssh_setup_conn(
777769
ssh_subtransport *t,
778770
const char *url,

tests/libgit2/online/clone.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -787,19 +787,10 @@ static int ssh_certificate_check(git_cert *cert, int valid, const char *host, vo
787787
{
788788
git_cert_hostkey *key;
789789
git_oid expected = GIT_OID_SHA1_ZERO, actual = GIT_OID_SHA1_ZERO;
790-
git_str expected_host = GIT_STR_INIT;
791-
git_net_url parsed_url = GIT_NET_URL_INIT;
792790

793791
GIT_UNUSED(valid);
794792
GIT_UNUSED(payload);
795793

796-
cl_git_pass(git_net_url_parse_standard_or_scp(&parsed_url, _remote_url));
797-
cl_git_pass(git_str_printf(&expected_host, "%s%s%s",
798-
parsed_url.host,
799-
git_net_url_is_default_port(&parsed_url) ? "" : ":",
800-
git_net_url_is_default_port(&parsed_url) ? "" : parsed_url.port));
801-
cl_assert_equal_s(expected_host.ptr, host);
802-
803794
cl_assert(_remote_ssh_fingerprint);
804795

805796
cl_git_pass(git_oid__fromstrp(&expected, _remote_ssh_fingerprint, GIT_OID_SHA1));
@@ -821,8 +812,7 @@ static int ssh_certificate_check(git_cert *cert, int valid, const char *host, vo
821812

822813
cl_assert(!memcmp(&expected, &actual, 20));
823814

824-
git_net_url_dispose(&parsed_url);
825-
git_str_dispose(&expected_host);
815+
cl_assert_equal_s("localhost", host);
826816

827817
return GIT_EUSER;
828818
}

0 commit comments

Comments
 (0)
0