1
1

Fix SSH1 and stdint in SSH1 code.

Этот коммит содержится в:
Andreas Schneider 2009-07-27 23:13:24 +02:00
родитель 26d1ac325b
Коммит 291522772d

Просмотреть файл

@ -245,7 +245,7 @@ static int packet_read1(SSH_SESSION *session) {
} }
} }
rc = ssh_socket_read(session->socket, &len, sizeof(u32)); rc = ssh_socket_read(session->socket, &len, sizeof(uint32_t));
if (rc != SSH_OK) { if (rc != SSH_OK) {
goto error; goto error;
} }
@ -312,29 +312,29 @@ static int packet_read1(SSH_SESSION *session) {
#endif #endif
ssh_log(session, SSH_LOG_PACKET, "%d bytes padding", padding); ssh_log(session, SSH_LOG_PACKET, "%d bytes padding", padding);
if(((len + padding) != buffer_get_rest_len(session->in_buffer)) || if(((len + padding) != buffer_get_rest_len(session->in_buffer)) ||
((len + padding) < sizeof(u32))) { ((len + padding) < sizeof(uint32_t))) {
ssh_log(session, SSH_LOG_RARE, "no crc32 in packet"); ssh_log(session, SSH_LOG_RARE, "no crc32 in packet");
ssh_set_error(session, SSH_FATAL, "no crc32 in packet"); ssh_set_error(session, SSH_FATAL, "no crc32 in packet");
goto error; goto error;
} }
memcpy(&crc, memcpy(&crc,
buffer_get_rest(session->in_buffer) + (len+padding) - sizeof(u32), buffer_get_rest(session->in_buffer) + (len+padding) - sizeof(uint32_t),
sizeof(u32)); sizeof(uint32_t));
buffer_pass_bytes_end(session->in_buffer, sizeof(u32)); buffer_pass_bytes_end(session->in_buffer, sizeof(uint32_t));
crc = ntohl(crc); crc = ntohl(crc);
if (ssh_crc32(buffer_get_rest(session->in_buffer), if (ssh_crc32(buffer_get_rest(session->in_buffer),
(len + padding) - sizeof(u32)) != crc) { (len + padding) - sizeof(uint32_t)) != crc) {
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("crc32 on",buffer_get_rest(session->in_buffer), ssh_print_hexa("crc32 on",buffer_get_rest(session->in_buffer),
len + padding - sizeof(u32)); len + padding - sizeof(uint32_t));
#endif #endif
ssh_log(session, SSH_LOG_RARE, "Invalid crc32"); ssh_log(session, SSH_LOG_RARE, "Invalid crc32");
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
"Invalid crc32: expected %.8x, got %.8x", "Invalid crc32: expected %.8x, got %.8x",
crc, crc,
ssh_crc32(buffer_get_rest(session->in_buffer), ssh_crc32(buffer_get_rest(session->in_buffer),
len + padding - sizeof(u32))); len + padding - sizeof(uint32_t)));
goto error; goto error;
} }
/* pass the padding */ /* pass the padding */
@ -502,11 +502,11 @@ error:
return rc; /* SSH_OK, AGAIN or ERROR */ return rc; /* SSH_OK, AGAIN or ERROR */
} }
#ifdef HAVE_SSH1 #ifdef WITH_SSH1
static int packet_send1(SSH_SESSION *session) { static int packet_send1(SSH_SESSION *session) {
unsigned int blocksize = (session->current_crypto ? unsigned int blocksize = (session->current_crypto ?
session->current_crypto->out_cipher->blocksize : 8); session->current_crypto->out_cipher->blocksize : 8);
uint32_t currentlen = buffer_get_len(session->out_buffer) + sizeof(u32); uint32_t currentlen = buffer_get_len(session->out_buffer) + sizeof(uint32_t);
char padstring[32] = {0}; char padstring[32] = {0};
int rc = SSH_ERROR; int rc = SSH_ERROR;
uint32_t finallen; uint32_t finallen;
@ -583,7 +583,7 @@ error:
#endif /* HAVE_SSH1 */ #endif /* HAVE_SSH1 */
int packet_send(SSH_SESSION *session) { int packet_send(SSH_SESSION *session) {
#ifdef HAVE_SSH1 #ifdef WITH_SSH1
if (session->version == 1) { if (session->version == 1) {
return packet_send1(session); return packet_send1(session);
} }