- markus@cvs.openbsd.org 2002/02/24 16:58:32
[packet.c] make 'cp' unsigned and merge with 'ucp'; ok stevesk@
This commit is contained in:
parent
021fcd3a36
commit
4a7714a43a
|
@ -32,6 +32,9 @@
|
||||||
- markus@cvs.openbsd.org 2002/02/24 16:57:19
|
- markus@cvs.openbsd.org 2002/02/24 16:57:19
|
||||||
[sftp-client.c]
|
[sftp-client.c]
|
||||||
early close(), missing free; ok stevesk@
|
early close(), missing free; ok stevesk@
|
||||||
|
- markus@cvs.openbsd.org 2002/02/24 16:58:32
|
||||||
|
[packet.c]
|
||||||
|
make 'cp' unsigned and merge with 'ucp'; ok stevesk@
|
||||||
|
|
||||||
20020225
|
20020225
|
||||||
- (bal) Last AIX patch. Moved aix_usrinfo() outside of do_setuserconext()
|
- (bal) Last AIX patch. Moved aix_usrinfo() outside of do_setuserconext()
|
||||||
|
@ -7705,4 +7708,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1882 2002/02/26 18:02:43 mouring Exp $
|
$Id: ChangeLog,v 1.1883 2002/02/26 18:04:38 mouring Exp $
|
||||||
|
|
38
packet.c
38
packet.c
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: packet.c,v 1.88 2002/02/14 23:41:01 markus Exp $");
|
RCSID("$OpenBSD: packet.c,v 1.89 2002/02/24 16:58:32 markus Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
@ -365,7 +365,7 @@ packet_put_bignum2(BIGNUM * value)
|
||||||
static void
|
static void
|
||||||
packet_send1(void)
|
packet_send1(void)
|
||||||
{
|
{
|
||||||
char buf[8], *cp;
|
u_char buf[8], *cp;
|
||||||
int i, padding, len;
|
int i, padding, len;
|
||||||
u_int checksum;
|
u_int checksum;
|
||||||
u_int32_t rand = 0;
|
u_int32_t rand = 0;
|
||||||
|
@ -496,9 +496,8 @@ static void
|
||||||
packet_send2(void)
|
packet_send2(void)
|
||||||
{
|
{
|
||||||
static u_int32_t seqnr = 0;
|
static u_int32_t seqnr = 0;
|
||||||
u_char type, *ucp, *macbuf = NULL;
|
u_char type, *cp, *macbuf = NULL;
|
||||||
u_char padlen, pad;
|
u_char padlen, pad;
|
||||||
char *cp;
|
|
||||||
u_int packet_length = 0;
|
u_int packet_length = 0;
|
||||||
u_int i, len;
|
u_int i, len;
|
||||||
u_int32_t rand = 0;
|
u_int32_t rand = 0;
|
||||||
|
@ -514,8 +513,8 @@ packet_send2(void)
|
||||||
}
|
}
|
||||||
block_size = enc ? enc->block_size : 8;
|
block_size = enc ? enc->block_size : 8;
|
||||||
|
|
||||||
ucp = buffer_ptr(&outgoing_packet);
|
cp = buffer_ptr(&outgoing_packet);
|
||||||
type = ucp[5];
|
type = cp[5];
|
||||||
|
|
||||||
#ifdef PACKET_DEBUG
|
#ifdef PACKET_DEBUG
|
||||||
fprintf(stderr, "plain: ");
|
fprintf(stderr, "plain: ");
|
||||||
|
@ -570,9 +569,9 @@ packet_send2(void)
|
||||||
}
|
}
|
||||||
/* packet_length includes payload, padding and padding length field */
|
/* packet_length includes payload, padding and padding length field */
|
||||||
packet_length = buffer_len(&outgoing_packet) - 4;
|
packet_length = buffer_len(&outgoing_packet) - 4;
|
||||||
ucp = buffer_ptr(&outgoing_packet);
|
cp = buffer_ptr(&outgoing_packet);
|
||||||
PUT_32BIT(ucp, packet_length);
|
PUT_32BIT(cp, packet_length);
|
||||||
ucp[4] = padlen;
|
cp[4] = padlen;
|
||||||
DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen));
|
DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen));
|
||||||
|
|
||||||
/* compute MAC over seqnr and packet(length fields, payload, padding) */
|
/* compute MAC over seqnr and packet(length fields, payload, padding) */
|
||||||
|
@ -709,16 +708,15 @@ static int
|
||||||
packet_read_poll1(void)
|
packet_read_poll1(void)
|
||||||
{
|
{
|
||||||
u_int len, padded_len;
|
u_int len, padded_len;
|
||||||
u_char *ucp, type;
|
u_char *cp, type;
|
||||||
char *cp;
|
|
||||||
u_int checksum, stored_checksum;
|
u_int checksum, stored_checksum;
|
||||||
|
|
||||||
/* Check if input size is less than minimum packet size. */
|
/* Check if input size is less than minimum packet size. */
|
||||||
if (buffer_len(&input) < 4 + 8)
|
if (buffer_len(&input) < 4 + 8)
|
||||||
return SSH_MSG_NONE;
|
return SSH_MSG_NONE;
|
||||||
/* Get length of incoming packet. */
|
/* Get length of incoming packet. */
|
||||||
ucp = buffer_ptr(&input);
|
cp = buffer_ptr(&input);
|
||||||
len = GET_32BIT(ucp);
|
len = GET_32BIT(cp);
|
||||||
if (len < 1 + 2 + 2 || len > 256 * 1024)
|
if (len < 1 + 2 + 2 || len > 256 * 1024)
|
||||||
packet_disconnect("Bad packet length %d.", len);
|
packet_disconnect("Bad packet length %d.", len);
|
||||||
padded_len = (len + 8) & ~7;
|
padded_len = (len + 8) & ~7;
|
||||||
|
@ -765,8 +763,8 @@ packet_read_poll1(void)
|
||||||
packet_disconnect("packet_read_poll1: len %d != buffer_len %d.",
|
packet_disconnect("packet_read_poll1: len %d != buffer_len %d.",
|
||||||
len, buffer_len(&incoming_packet));
|
len, buffer_len(&incoming_packet));
|
||||||
|
|
||||||
ucp = (u_char *)buffer_ptr(&incoming_packet) + len - 4;
|
cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4;
|
||||||
stored_checksum = GET_32BIT(ucp);
|
stored_checksum = GET_32BIT(cp);
|
||||||
if (checksum != stored_checksum)
|
if (checksum != stored_checksum)
|
||||||
packet_disconnect("Corrupted check bytes on input.");
|
packet_disconnect("Corrupted check bytes on input.");
|
||||||
buffer_consume_end(&incoming_packet, 4);
|
buffer_consume_end(&incoming_packet, 4);
|
||||||
|
@ -788,8 +786,7 @@ packet_read_poll2(u_int32_t *seqnr_p)
|
||||||
static u_int32_t seqnr = 0;
|
static u_int32_t seqnr = 0;
|
||||||
static u_int packet_length = 0;
|
static u_int packet_length = 0;
|
||||||
u_int padlen, need;
|
u_int padlen, need;
|
||||||
u_char *macbuf, *ucp, type;
|
u_char *macbuf, *cp, type;
|
||||||
char *cp;
|
|
||||||
int maclen, block_size;
|
int maclen, block_size;
|
||||||
Enc *enc = NULL;
|
Enc *enc = NULL;
|
||||||
Mac *mac = NULL;
|
Mac *mac = NULL;
|
||||||
|
@ -814,8 +811,8 @@ packet_read_poll2(u_int32_t *seqnr_p)
|
||||||
cp = buffer_append_space(&incoming_packet, block_size);
|
cp = buffer_append_space(&incoming_packet, block_size);
|
||||||
cipher_crypt(&receive_context, cp, buffer_ptr(&input),
|
cipher_crypt(&receive_context, cp, buffer_ptr(&input),
|
||||||
block_size);
|
block_size);
|
||||||
ucp = buffer_ptr(&incoming_packet);
|
cp = buffer_ptr(&incoming_packet);
|
||||||
packet_length = GET_32BIT(ucp);
|
packet_length = GET_32BIT(cp);
|
||||||
if (packet_length < 1 + 4 || packet_length > 256 * 1024) {
|
if (packet_length < 1 + 4 || packet_length > 256 * 1024) {
|
||||||
buffer_dump(&incoming_packet);
|
buffer_dump(&incoming_packet);
|
||||||
packet_disconnect("Bad packet length %d.", packet_length);
|
packet_disconnect("Bad packet length %d.", packet_length);
|
||||||
|
@ -863,8 +860,7 @@ packet_read_poll2(u_int32_t *seqnr_p)
|
||||||
|
|
||||||
/* get padlen */
|
/* get padlen */
|
||||||
cp = buffer_ptr(&incoming_packet);
|
cp = buffer_ptr(&incoming_packet);
|
||||||
cp += 4;
|
padlen = cp[4];
|
||||||
padlen = (u_char) *cp;
|
|
||||||
DBG(debug("input: padlen %d", padlen));
|
DBG(debug("input: padlen %d", padlen));
|
||||||
if (padlen < 4)
|
if (padlen < 4)
|
||||||
packet_disconnect("Corrupted padlen %d on input.", padlen);
|
packet_disconnect("Corrupted padlen %d on input.", padlen);
|
||||||
|
|
Loading…
Reference in New Issue