if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) \
fprintf(stderr, "%s\n", s); }
-#define bombout(msg) ( ssh_state = SSH_STATE_CLOSED, sk_close(s), \
- s = NULL, connection_fatal msg )
+#define bombout(msg) ( ssh_state = SSH_STATE_CLOSED, \
+ (s ? sk_close(s), s = NULL : (void)0), \
+ connection_fatal msg )
#define SSH1_MSG_DISCONNECT 1 /* 0x1 */
#define SSH1_SMSG_PUBLIC_KEY 2 /* 0x2 */
if (urgent==3) {
/* A socket error has occurred. */
ssh_state = SSH_STATE_CLOSED;
+ sk_close(s);
s = NULL;
connection_fatal(data);
- len = 0;
- }
- if (!len) {
+ return 0;
+ } else if (!len) {
/* Connection has closed. */
ssh_state = SSH_STATE_CLOSED;
sk_close(s);
/*
* Open socket.
*/
- s = sk_new(addr, port, 0, ssh_receive);
+ s = sk_new(addr, port, 0, 1, ssh_receive);
if ( (err = sk_socket_error(s)) )
return err;
* transport. If we ever see a KEXINIT, we must go back to the
* start.
*/
- do {
+ while (!(ispkt && pktin.type == SSH2_MSG_KEXINIT)) {
crReturn(1);
- } while (!(ispkt && pktin.type == SSH2_MSG_KEXINIT));
+ }
logevent("Server initiated key re-exchange");
goto begin_key_exchange;