|
Lines 1177-1182
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1177 |
ssh->kex->client_version : ssh->kex->server_version; |
1177 |
ssh->kex->client_version : ssh->kex->server_version; |
| 1178 |
char *our_version_string = NULL, *peer_version_string = NULL; |
1178 |
char *our_version_string = NULL, *peer_version_string = NULL; |
| 1179 |
char *cp, *remote_version = NULL; |
1179 |
char *cp, *remote_version = NULL; |
|
|
1180 |
char remote_id[512]; |
| 1181 |
|
| 1182 |
sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); |
| 1180 |
|
1183 |
|
| 1181 |
/* Prepare and send our banner */ |
1184 |
/* Prepare and send our banner */ |
| 1182 |
sshbuf_reset(our_version); |
1185 |
sshbuf_reset(our_version); |
|
Lines 1215-1221
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1215 |
send_error(ssh, "No SSH identification string " |
1218 |
send_error(ssh, "No SSH identification string " |
| 1216 |
"received."); |
1219 |
"received."); |
| 1217 |
error("%s: No SSH version received in first %u lines " |
1220 |
error("%s: No SSH version received in first %u lines " |
| 1218 |
"from server", __func__, SSH_MAX_PRE_BANNER_LINES); |
1221 |
"from server %s", __func__, |
|
|
1222 |
SSH_MAX_PRE_BANNER_LINES, remote_id); |
| 1219 |
r = SSH_ERR_INVALID_FORMAT; |
1223 |
r = SSH_ERR_INVALID_FORMAT; |
| 1220 |
goto out; |
1224 |
goto out; |
| 1221 |
} |
1225 |
} |
|
Lines 1229-1240
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1229 |
send_error(ssh, "Timed out waiting " |
1233 |
send_error(ssh, "Timed out waiting " |
| 1230 |
"for SSH identification string."); |
1234 |
"for SSH identification string."); |
| 1231 |
error("Connection timed out during " |
1235 |
error("Connection timed out during " |
| 1232 |
"banner exchange"); |
1236 |
"banner exchange with peer %s", |
|
|
1237 |
remote_id); |
| 1233 |
r = SSH_ERR_CONN_TIMEOUT; |
1238 |
r = SSH_ERR_CONN_TIMEOUT; |
| 1234 |
goto out; |
1239 |
goto out; |
| 1235 |
} else if (r == -1) { |
1240 |
} else if (r == -1) { |
| 1236 |
error("%s: %s", |
1241 |
error("%s: %s with peer %s", __func__, |
| 1237 |
__func__, strerror(errno)); |
1242 |
strerror(errno), remote_id); |
| 1238 |
r = SSH_ERR_SYSTEM_ERROR; |
1243 |
r = SSH_ERR_SYSTEM_ERROR; |
| 1239 |
goto out; |
1244 |
goto out; |
| 1240 |
} |
1245 |
} |
|
Lines 1243-1255
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1243 |
len = atomicio(read, ssh_packet_get_connection_in(ssh), |
1248 |
len = atomicio(read, ssh_packet_get_connection_in(ssh), |
| 1244 |
&c, 1); |
1249 |
&c, 1); |
| 1245 |
if (len != 1 && errno == EPIPE) { |
1250 |
if (len != 1 && errno == EPIPE) { |
| 1246 |
error("%s: Connection closed by remote host", |
1251 |
error("%s: Connection closed by remote host %s", |
| 1247 |
__func__); |
1252 |
__func__, remote_id); |
| 1248 |
r = SSH_ERR_CONN_CLOSED; |
1253 |
r = SSH_ERR_CONN_CLOSED; |
| 1249 |
goto out; |
1254 |
goto out; |
| 1250 |
} else if (len != 1) { |
1255 |
} else if (len != 1) { |
| 1251 |
error("%s: read: %.100s", |
1256 |
error("%s: peer %s read: %.100s", |
| 1252 |
__func__, strerror(errno)); |
1257 |
__func__, remote_id, strerror(errno)); |
| 1253 |
r = SSH_ERR_SYSTEM_ERROR; |
1258 |
r = SSH_ERR_SYSTEM_ERROR; |
| 1254 |
goto out; |
1259 |
goto out; |
| 1255 |
} |
1260 |
} |
|
Lines 1310-1317
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1310 |
*/ |
1315 |
*/ |
| 1311 |
if (sscanf(peer_version_string, "SSH-%d.%d-%[^\n]\n", |
1316 |
if (sscanf(peer_version_string, "SSH-%d.%d-%[^\n]\n", |
| 1312 |
&remote_major, &remote_minor, remote_version) != 3) { |
1317 |
&remote_major, &remote_minor, remote_version) != 3) { |
| 1313 |
error("Bad remote protocol version identification: '%.100s'", |
1318 |
error("Bad remote protocol version identification from peer " |
| 1314 |
peer_version_string); |
1319 |
"%s: '%.100s'", remote_id, peer_version_string); |
| 1315 |
invalid: |
1320 |
invalid: |
| 1316 |
send_error(ssh, "Invalid SSH identification string."); |
1321 |
send_error(ssh, "Invalid SSH identification string."); |
| 1317 |
r = SSH_ERR_INVALID_FORMAT; |
1322 |
r = SSH_ERR_INVALID_FORMAT; |
|
Lines 1334-1341
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
Link Here
|
| 1334 |
break; |
1339 |
break; |
| 1335 |
} |
1340 |
} |
| 1336 |
if (mismatch) { |
1341 |
if (mismatch) { |
| 1337 |
error("Protocol major versions differ: %d vs. %d", |
1342 |
error("Protocol major versions differ with peer %s: %d vs. %d", |
| 1338 |
PROTOCOL_MAJOR_2, remote_major); |
1343 |
remote_id, PROTOCOL_MAJOR_2, remote_major); |
| 1339 |
send_error(ssh, "Protocol major versions differ."); |
1344 |
send_error(ssh, "Protocol major versions differ."); |
| 1340 |
r = SSH_ERR_NO_PROTOCOL_VERSION; |
1345 |
r = SSH_ERR_NO_PROTOCOL_VERSION; |
| 1341 |
goto out; |
1346 |
goto out; |