version 1.102.2.1, 2003/09/16 20:50:43 |
version 1.102.2.2, 2004/03/04 18:18:16 |
|
|
buffer_init(&incoming_packet); |
buffer_init(&incoming_packet); |
TAILQ_INIT(&outgoing); |
TAILQ_INIT(&outgoing); |
} |
} |
/* Kludge: arrange the close function to be called from fatal(). */ |
|
fatal_add_cleanup((void (*) (void *)) packet_close, NULL); |
|
} |
} |
|
|
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
|
|
len = read(connection_in, buf, sizeof(buf)); |
len = read(connection_in, buf, sizeof(buf)); |
if (len == 0) { |
if (len == 0) { |
logit("Connection closed by %.200s", get_remote_ipaddr()); |
logit("Connection closed by %.200s", get_remote_ipaddr()); |
fatal_cleanup(); |
cleanup_exit(255); |
} |
} |
if (len < 0) |
if (len < 0) |
fatal("Read from socket failed: %.100s", strerror(errno)); |
fatal("Read from socket failed: %.100s", strerror(errno)); |
|
|
cp = buffer_ptr(&incoming_packet); |
cp = buffer_ptr(&incoming_packet); |
packet_length = GET_32BIT(cp); |
packet_length = GET_32BIT(cp); |
if (packet_length < 1 + 4 || packet_length > 256 * 1024) { |
if (packet_length < 1 + 4 || packet_length > 256 * 1024) { |
|
#ifdef PACKET_DEBUG |
buffer_dump(&incoming_packet); |
buffer_dump(&incoming_packet); |
|
#endif |
packet_disconnect("Bad packet length %u.", packet_length); |
packet_disconnect("Bad packet length %u.", packet_length); |
} |
} |
DBG(debug("input: packet len %u", packet_length+4)); |
DBG(debug("input: packet len %u", packet_length+4)); |
|
|
logit("Received disconnect from %s: %u: %.400s", |
logit("Received disconnect from %s: %u: %.400s", |
get_remote_ipaddr(), reason, msg); |
get_remote_ipaddr(), reason, msg); |
xfree(msg); |
xfree(msg); |
fatal_cleanup(); |
cleanup_exit(255); |
break; |
break; |
case SSH2_MSG_UNIMPLEMENTED: |
case SSH2_MSG_UNIMPLEMENTED: |
seqnr = packet_get_int(); |
seqnr = packet_get_int(); |
|
|
msg = packet_get_string(NULL); |
msg = packet_get_string(NULL); |
logit("Received disconnect from %s: %.400s", |
logit("Received disconnect from %s: %.400s", |
get_remote_ipaddr(), msg); |
get_remote_ipaddr(), msg); |
fatal_cleanup(); |
cleanup_exit(255); |
xfree(msg); |
xfree(msg); |
break; |
break; |
default: |
default: |
|
|
|
|
/* Close the connection. */ |
/* Close the connection. */ |
packet_close(); |
packet_close(); |
|
cleanup_exit(255); |
fatal_cleanup(); |
|
} |
} |
|
|
/* Checks if there is any buffered output, and tries to write some of the output. */ |
/* Checks if there is any buffered output, and tries to write some of the output. */ |