Add some PACKET functions for size_t
And use them in the DTLS code Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
parent
8051ab2b6f
commit
153703dfde
2 changed files with 55 additions and 3 deletions
|
@ -579,10 +579,10 @@ int DTLSv1_listen(SSL *s, BIO_ADDR *client)
|
|||
|
||||
/* Finished processing the record header, now process the message */
|
||||
if (!PACKET_get_1(&msgpkt, &msgtype)
|
||||
|| !PACKET_get_net_3(&msgpkt, &msglen)
|
||||
|| !PACKET_get_net_3_len(&msgpkt, &msglen)
|
||||
|| !PACKET_get_net_2(&msgpkt, &msgseq)
|
||||
|| !PACKET_get_net_3(&msgpkt, &fragoff)
|
||||
|| !PACKET_get_net_3(&msgpkt, &fraglen)
|
||||
|| !PACKET_get_net_3_len(&msgpkt, &fragoff)
|
||||
|| !PACKET_get_net_3_len(&msgpkt, &fraglen)
|
||||
|| !PACKET_get_sub_packet(&msgpkt, &msgpayload, fraglen)
|
||||
|| PACKET_remaining(&msgpkt) != 0) {
|
||||
SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);
|
||||
|
|
|
@ -160,6 +160,19 @@ __owur static ossl_inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Same as PACKET_get_net_2() but for a size_t */
|
||||
__owur static ossl_inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data)
|
||||
{
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
ret = PACKET_get_net_2(pkt, &i);
|
||||
if (ret)
|
||||
*data = (size_t)i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Peek ahead at 3 bytes in network order from |pkt| and store the value in
|
||||
* |*data|
|
||||
|
@ -189,6 +202,19 @@ __owur static ossl_inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Same as PACKET_get_net_3() but for a size_t */
|
||||
__owur static ossl_inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data)
|
||||
{
|
||||
unsigned long i;
|
||||
int ret;
|
||||
|
||||
ret = PACKET_get_net_3(pkt, &i);
|
||||
if (ret)
|
||||
*data = (size_t)i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Peek ahead at 4 bytes in network order from |pkt| and store the value in
|
||||
* |*data|
|
||||
|
@ -219,6 +245,19 @@ __owur static ossl_inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Same as PACKET_get_net_4() but for a size_t */
|
||||
__owur static ossl_inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data)
|
||||
{
|
||||
unsigned long i;
|
||||
int ret;
|
||||
|
||||
ret = PACKET_get_net_4(pkt, &i);
|
||||
if (ret)
|
||||
*data = (size_t)i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Peek ahead at 1 byte from |pkt| and store the value in |*data| */
|
||||
__owur static ossl_inline int PACKET_peek_1(const PACKET *pkt,
|
||||
unsigned int *data)
|
||||
|
@ -242,6 +281,19 @@ __owur static ossl_inline int PACKET_get_1(PACKET *pkt, unsigned int *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Same as PACKET_get_1() but for a size_t */
|
||||
__owur static ossl_inline int PACKET_get_1_len(PACKET *pkt, size_t *data)
|
||||
{
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
ret = PACKET_get_1(pkt, &i);
|
||||
if (ret)
|
||||
*data = (size_t)i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Peek ahead at 4 bytes in reverse network order from |pkt| and store the value
|
||||
* in |*data|
|
||||
|
|
Loading…
Reference in a new issue