View | Details | Raw Unified | Return to bug 3129 | Differences between
and this patch

Collapse All | Expand All

(-)a/kex.c (-2 / +10 lines)
Lines 1167-1173 int Link Here
1167
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
1167
kex_exchange_identification(struct ssh *ssh, int timeout_ms,
1168
    const char *version_addendum)
1168
    const char *version_addendum)
1169
{
1169
{
1170
	int remote_major, remote_minor, mismatch;
1170
	int remote_major, remote_minor, mismatch, oerrno = 0;
1171
	size_t len, i, n;
1171
	size_t len, i, n;
1172
	int r, expect_nl;
1172
	int r, expect_nl;
1173
	u_char c;
1173
	u_char c;
Lines 1186-1191 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1186
	   PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION,
1186
	   PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION,
1187
	    version_addendum == NULL ? "" : " ",
1187
	    version_addendum == NULL ? "" : " ",
1188
	    version_addendum == NULL ? "" : version_addendum)) != 0) {
1188
	    version_addendum == NULL ? "" : version_addendum)) != 0) {
1189
		oerrno = errno;
1189
		error("%s: sshbuf_putf: %s", __func__, ssh_err(r));
1190
		error("%s: sshbuf_putf: %s", __func__, ssh_err(r));
1190
		goto out;
1191
		goto out;
1191
	}
1192
	}
Lines 1193-1203 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1193
	if (atomicio(vwrite, ssh_packet_get_connection_out(ssh),
1194
	if (atomicio(vwrite, ssh_packet_get_connection_out(ssh),
1194
	    sshbuf_mutable_ptr(our_version),
1195
	    sshbuf_mutable_ptr(our_version),
1195
	    sshbuf_len(our_version)) != sshbuf_len(our_version)) {
1196
	    sshbuf_len(our_version)) != sshbuf_len(our_version)) {
1196
		error("%s: write: %.100s", __func__, strerror(errno));
1197
		oerrno = errno;
1198
		debug("%s: write: %.100s", __func__, strerror(errno));
1197
		r = SSH_ERR_SYSTEM_ERROR;
1199
		r = SSH_ERR_SYSTEM_ERROR;
1198
		goto out;
1200
		goto out;
1199
	}
1201
	}
1200
	if ((r = sshbuf_consume_end(our_version, 2)) != 0) { /* trim \r\n */
1202
	if ((r = sshbuf_consume_end(our_version, 2)) != 0) { /* trim \r\n */
1203
		oerrno = errno;
1201
		error("%s: sshbuf_consume_end: %s", __func__, ssh_err(r));
1204
		error("%s: sshbuf_consume_end: %s", __func__, ssh_err(r));
1202
		goto out;
1205
		goto out;
1203
	}
1206
	}
Lines 1233-1238 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1233
					r = SSH_ERR_CONN_TIMEOUT;
1236
					r = SSH_ERR_CONN_TIMEOUT;
1234
					goto out;
1237
					goto out;
1235
				} else if (r == -1) {
1238
				} else if (r == -1) {
1239
					oerrno = errno;
1236
					error("%s: %s",
1240
					error("%s: %s",
1237
					    __func__, strerror(errno));
1241
					    __func__, strerror(errno));
1238
					r = SSH_ERR_SYSTEM_ERROR;
1242
					r = SSH_ERR_SYSTEM_ERROR;
Lines 1248-1253 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1248
				r = SSH_ERR_CONN_CLOSED;
1252
				r = SSH_ERR_CONN_CLOSED;
1249
				goto out;
1253
				goto out;
1250
			} else if (len != 1) {
1254
			} else if (len != 1) {
1255
				oerrno = errno;
1251
				error("%s: read: %.100s",
1256
				error("%s: read: %.100s",
1252
				    __func__, strerror(errno));
1257
				    __func__, strerror(errno));
1253
				r = SSH_ERR_SYSTEM_ERROR;
1258
				r = SSH_ERR_SYSTEM_ERROR;
Lines 1265-1270 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1265
				goto invalid;
1270
				goto invalid;
1266
			}
1271
			}
1267
			if ((r = sshbuf_put_u8(peer_version, c)) != 0) {
1272
			if ((r = sshbuf_put_u8(peer_version, c)) != 0) {
1273
				oerrno = errno;
1268
				error("%s: sshbuf_put: %s",
1274
				error("%s: sshbuf_put: %s",
1269
				    __func__, ssh_err(r));
1275
				    __func__, ssh_err(r));
1270
				goto out;
1276
				goto out;
Lines 1365-1370 kex_exchange_identification(struct ssh *ssh, int timeout_ms, Link Here
1365
	free(our_version_string);
1371
	free(our_version_string);
1366
	free(peer_version_string);
1372
	free(peer_version_string);
1367
	free(remote_version);
1373
	free(remote_version);
1374
	if (r == SSH_ERR_SYSTEM_ERROR)
1375
		errno = oerrno;
1368
	return r;
1376
	return r;
1369
}
1377
}
1370
1378
(-)a/sshconnect.c (-2 / +3 lines)
Lines 1276-1281 ssh_login(struct ssh *ssh, Sensitive *sensitive, const char *orighost, Link Here
1276
{
1276
{
1277
	char *host;
1277
	char *host;
1278
	char *server_user, *local_user;
1278
	char *server_user, *local_user;
1279
	int r;
1279
1280
1280
	local_user = xstrdup(pw->pw_name);
1281
	local_user = xstrdup(pw->pw_name);
1281
	server_user = options.user ? options.user : local_user;
1282
	server_user = options.user ? options.user : local_user;
Lines 1285-1292 ssh_login(struct ssh *ssh, Sensitive *sensitive, const char *orighost, Link Here
1285
	lowercase(host);
1286
	lowercase(host);
1286
1287
1287
	/* Exchange protocol version identification strings with the server. */
1288
	/* Exchange protocol version identification strings with the server. */
1288
	if (kex_exchange_identification(ssh, timeout_ms, NULL) != 0)
1289
	if ((r = kex_exchange_identification(ssh, timeout_ms, NULL)) != 0)
1289
		cleanup_exit(255); /* error already logged */
1290
		sshpkt_fatal(ssh, r, "banner exchange");
1290
1291
1291
	/* Put the connection into non-blocking mode. */
1292
	/* Put the connection into non-blocking mode. */
1292
	ssh_packet_set_nonblocking(ssh);
1293
	ssh_packet_set_nonblocking(ssh);
(-)a/sshd.c (-2 / +3 lines)
Lines 2161-2168 main(int ac, char **av) Link Here
2161
	if (!debug_flag)
2161
	if (!debug_flag)
2162
		alarm(options.login_grace_time);
2162
		alarm(options.login_grace_time);
2163
2163
2164
	if (kex_exchange_identification(ssh, -1, options.version_addendum) != 0)
2164
	if ((r = kex_exchange_identification(ssh, -1,
2165
		cleanup_exit(255); /* error already logged */
2165
	    options.version_addendum)) != 0)
2166
		sshpkt_fatal(ssh, r, "banner exchange");
2166
2167
2167
	ssh_packet_set_nonblocking(ssh);
2168
	ssh_packet_set_nonblocking(ssh);
2168
2169

Return to bug 3129