mirror of
https://github.com/openssh/libopenssh
synced 2026-04-16 09:45:53 +00:00
replace ssh_packet_payload() with sshpkt_ptr(); adapt ssh_packet_payload()
sshpkt_ptr() has similar argument/return types as sshbuf_ptr() u_int -> size_t, void * -> u_char.
This commit is contained in:
@@ -246,15 +246,16 @@ int
|
||||
kex_input_kexinit(int type, u_int32_t seq, struct ssh *ssh)
|
||||
{
|
||||
Kex *kex = ssh->kex;
|
||||
char *ptr;
|
||||
u_int i, dlen;
|
||||
u_char *ptr;
|
||||
u_int i;
|
||||
size_t dlen;
|
||||
int r;
|
||||
|
||||
debug("SSH2_MSG_KEXINIT received");
|
||||
if (kex == NULL)
|
||||
return SSH_ERR_INVALID_ARGUMENT;
|
||||
|
||||
ptr = ssh_packet_get_raw(ssh, &dlen);
|
||||
ptr = sshpkt_ptr(ssh, &dlen);
|
||||
if ((r = sshbuf_put(kex->peer, ptr, dlen)) != 0)
|
||||
return r;
|
||||
|
||||
|
||||
19
ssh/packet.c
19
ssh/packet.c
@@ -1902,16 +1902,6 @@ ssh_packet_get_ecpoint(struct ssh *ssh, const EC_GROUP *curve, EC_POINT *point)
|
||||
fatal("%s: %s", __func__, ssh_err(r));
|
||||
}
|
||||
|
||||
void *
|
||||
ssh_packet_get_raw(struct ssh *ssh, u_int *length_ptr)
|
||||
{
|
||||
u_int bytes = sshbuf_len(ssh->state->incoming_packet);
|
||||
|
||||
if (length_ptr != NULL)
|
||||
*length_ptr = bytes;
|
||||
return sshbuf_ptr(ssh->state->incoming_packet);
|
||||
}
|
||||
|
||||
int
|
||||
ssh_packet_remaining(struct ssh *ssh)
|
||||
{
|
||||
@@ -2833,6 +2823,15 @@ sshpkt_get_end(struct ssh *ssh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u_char *
|
||||
sshpkt_ptr(struct ssh *ssh, size_t *lenp)
|
||||
{
|
||||
if (lenp != NULL)
|
||||
*lenp = sshbuf_len(ssh->state->incoming_packet);
|
||||
return sshbuf_ptr(ssh->state->incoming_packet);
|
||||
}
|
||||
|
||||
|
||||
/* start a new packet */
|
||||
|
||||
int
|
||||
|
||||
@@ -119,7 +119,6 @@ u_int64_t ssh_packet_get_int64(struct ssh *);
|
||||
void ssh_packet_get_bignum(struct ssh *, BIGNUM * value);
|
||||
void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value);
|
||||
void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *);
|
||||
void *ssh_packet_get_raw(struct ssh *, u_int *length_ptr);
|
||||
void *ssh_packet_get_string(struct ssh *, u_int *length_ptr);
|
||||
char *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr);
|
||||
const void *ssh_packet_get_string_ptr(struct ssh *, u_int *length_ptr);
|
||||
@@ -327,5 +326,6 @@ int sshpkt_get_ec(struct ssh *ssh, EC_POINT *v, const EC_GROUP *g);
|
||||
int sshpkt_get_bignum1(struct ssh *ssh, BIGNUM *v);
|
||||
int sshpkt_get_bignum2(struct ssh *ssh, BIGNUM *v);
|
||||
int sshpkt_get_end(struct ssh *ssh);
|
||||
u_char *sshpkt_ptr(struct ssh *, size_t *lenp);
|
||||
|
||||
#endif /* PACKET_H */
|
||||
|
||||
@@ -197,10 +197,10 @@ ssh_packet_next(struct ssh *ssh, u_char *typep)
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
ssh_packet_payload(struct ssh *ssh, size_t *len)
|
||||
u_char *
|
||||
ssh_packet_payload(struct ssh *ssh, size_t *lenp)
|
||||
{
|
||||
return (ssh_packet_get_raw(ssh, (u_int *)len));
|
||||
return sshpkt_ptr(ssh, lenp);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -70,7 +70,7 @@ int ssh_packet_next(struct ssh *ssh, u_char *typep);
|
||||
* the current input packet and the length of this payload.
|
||||
* the payload is accessible until ssh_packet_next() is called again.
|
||||
*/
|
||||
void *ssh_packet_payload(struct ssh *ssh, size_t *len);
|
||||
u_char *ssh_packet_payload(struct ssh *ssh, size_t *lenp);
|
||||
|
||||
/*
|
||||
* ssh_packet_put() creates an encrypted packet with the given type
|
||||
|
||||
@@ -26,7 +26,7 @@ static int
|
||||
do_send_and_receive(struct ssh *from, struct ssh *to)
|
||||
{
|
||||
u_char type;
|
||||
u_int len;
|
||||
size_t len;
|
||||
char *buf;
|
||||
int r;
|
||||
|
||||
@@ -37,9 +37,9 @@ do_send_and_receive(struct ssh *from, struct ssh *to)
|
||||
}
|
||||
if (type != 0)
|
||||
return 0;
|
||||
buf = ssh_output_ptr(from, (u_int *)&len);
|
||||
buf = ssh_output_ptr(from, &len);
|
||||
if (do_debug)
|
||||
printf("%u", len);
|
||||
printf("%zu", len);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
if ((r = ssh_output_consume(from, len)) != 0 ||
|
||||
|
||||
Reference in New Issue
Block a user