@@ -651,6 +651,8 @@ static int check_against_known_hosts(
651651 return ret ;
652652}
653653
654+ #define SSH_DEFAULT_PORT 22
655+
654656/*
655657 * Perform the check for the session's certificate against known hosts if
656658 * possible and then ask the user if they have a callback.
@@ -748,23 +750,29 @@ static int check_certificate(
748750 if (check_cb != NULL ) {
749751 git_cert_hostkey * cert_ptr = & cert ;
750752 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+ }
751760
752761 git_error_state_capture (& previous_error , error );
753- error = check_cb ((git_cert * ) cert_ptr , cert_valid , host , check_cb_payload );
762+ error = check_cb ((git_cert * ) cert_ptr , cert_valid , host_ptr , check_cb_payload );
754763 if (error == GIT_PASSTHROUGH ) {
755764 error = git_error_state_restore (& previous_error );
756765 } else if (error < 0 && !git_error_last ()) {
757766 git_error_set (GIT_ERROR_NET , "unknown remote host key" );
758767 }
759768
760769 git_error_state_free (& previous_error );
770+ git_str_dispose (& host_and_port );
761771 }
762772
763773 return error ;
764774}
765775
766- #define SSH_DEFAULT_PORT "22"
767-
768776static int _git_ssh_setup_conn (
769777 ssh_subtransport * t ,
770778 const char * url ,
0 commit comments