diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index aa6cdd2670..ffc63222b1 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -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); diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index cee14002bf..ec31a331d2 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -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|