File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -748,19 +748,21 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data,
748748 if (store ) {
749749 if (store -> name ) {
750750 if (store -> name [0 ] == '[' ) {
751- int port = 0 ;
751+ curl_off_t port ;
752752 size_t kh_name_size = 0 ;
753+ const char * p ;
753754 const char * kh_name_end = strstr (store -> name , "]:" );
754755 if (!kh_name_end ) {
755756 infof (data , "Invalid host pattern %s in %s" ,
756757 store -> name , data -> set .str [STRING_SSH_KNOWNHOSTS ]);
757758 continue ;
758759 }
759- port = atoi (kh_name_end + 2 );
760- if (kh_name_end && (port == conn -> remote_port )) {
760+ p = kh_name_end + 2 ; /* start of port number */
761+ if (!curlx_str_number (& p , & port , 0xffff ) &&
762+ (kh_name_end && (port == conn -> remote_port ))) {
761763 kh_name_size = strlen (store -> name ) - 1 - strlen (kh_name_end );
762764 if (strncmp (store -> name + 1 ,
763- conn -> host .name , kh_name_size ) == 0 ) {
765+ conn -> host .name , kh_name_size ) == 0 ) {
764766 found = TRUE;
765767 break ;
766768 }
You can’t perform that action at this time.
0 commit comments