summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2022-10-06 13:05:39 +0200
committerRichard Levitte <levitte@openssl.org>2022-10-25 13:25:00 +0200
commite251e7ba1ce85d11f3c342b3ae1326a35b7d0b4a (patch)
treebe3ee8365fd66557aa287e0a94902cd5f2cb7abe /ssl
parentFix 32-bit Windows issues related to QUIC_STREAM (diff)
downloadopenssl-e251e7ba1ce85d11f3c342b3ae1326a35b7d0b4a.tar.xz
openssl-e251e7ba1ce85d11f3c342b3ae1326a35b7d0b4a.zip
Fix 32-bit Windows issues related to QUIC Wire functions
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19345)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/quic/quic_wire.c33
-rw-r--r--ssl/quic/quic_wire_pkt.c6
2 files changed, 22 insertions, 17 deletions
diff --git a/ssl/quic/quic_wire.c b/ssl/quic/quic_wire.c
index 291a1bb0d7..e086834b5e 100644
--- a/ssl/quic/quic_wire.c
+++ b/ssl/quic/quic_wire.c
@@ -54,7 +54,7 @@ int ossl_quic_wire_encode_frame_ack(WPACKET *pkt,
return 0;
delay = ossl_time_divide(ossl_time_divide(ack->delay_time, OSSL_TIME_US),
- 1UL << ack_delay_exponent);
+ (uint64_t)1 << ack_delay_exponent);
ack_delay_enc = ossl_time2ticks(delay);
largest_ackd = ack->ack_ranges[0].end;
@@ -127,11 +127,12 @@ void *ossl_quic_wire_encode_frame_crypto(WPACKET *pkt,
unsigned char *p = NULL;
if (!ossl_quic_wire_encode_frame_crypto_hdr(pkt, f)
- || !WPACKET_allocate_bytes(pkt, f->len, &p))
+ || f->len > SIZE_MAX /* sizeof(uint64_t) > sizeof(size_t)? */
+ || !WPACKET_allocate_bytes(pkt, (size_t)f->len, &p))
return NULL;
if (f->data != NULL)
- memcpy(p, f->data, f->len);
+ memcpy(p, f->data, (size_t)f->len);
return p;
}
@@ -179,14 +180,15 @@ void *ossl_quic_wire_encode_frame_stream(WPACKET *pkt,
unsigned char *p = NULL;
- if (!ossl_quic_wire_encode_frame_stream_hdr(pkt, f))
+ if (!ossl_quic_wire_encode_frame_stream_hdr(pkt, f)
+ || f->len > SIZE_MAX /* sizeof(uint64_t) > sizeof(size_t)? */)
return NULL;
- if (!WPACKET_allocate_bytes(pkt, f->len, &p))
+ if (!WPACKET_allocate_bytes(pkt, (size_t)f->len, &p))
return NULL;
if (f->data != NULL)
- memcpy(p, f->data, f->len);
+ memcpy(p, f->data, (size_t)f->len);
return p;
}
@@ -450,7 +452,7 @@ int ossl_quic_wire_decode_frame_ack(PACKET *pkt,
ack->delay_time
= ossl_time_multiply(ossl_ticks2time(OSSL_TIME_US),
safe_mul_uint64_t(ack_delay_raw,
- 1UL << ack_delay_exponent,
+ (uint64_t)1 << ack_delay_exponent,
&err));
if (err)
ack->delay_time = ossl_time_infinite();
@@ -533,7 +535,8 @@ int ossl_quic_wire_decode_frame_crypto(PACKET *pkt,
{
if (!expect_frame_header(pkt, OSSL_QUIC_FRAME_TYPE_CRYPTO)
|| !PACKET_get_quic_vlint(pkt, &f->offset)
- || !PACKET_get_quic_vlint(pkt, &f->len))
+ || !PACKET_get_quic_vlint(pkt, &f->len)
+ || f->len > SIZE_MAX /* sizeof(uint64_t) > sizeof(size_t)? */)
return 0;
if (PACKET_remaining(pkt) < f->len)
@@ -541,7 +544,7 @@ int ossl_quic_wire_decode_frame_crypto(PACKET *pkt,
f->data = PACKET_data(pkt);
- if (!PACKET_forward(pkt, f->len))
+ if (!PACKET_forward(pkt, (size_t)f->len))
return 0;
return 1;
@@ -561,9 +564,9 @@ int ossl_quic_wire_decode_frame_new_token(PACKET *pkt,
return 0;
*token = PACKET_data(pkt);
- *token_len = token_len_;
+ *token_len = (size_t)token_len_;
- if (!PACKET_forward(pkt, token_len_))
+ if (!PACKET_forward(pkt, (size_t)token_len_))
return 0;
return 1;
@@ -600,7 +603,8 @@ int ossl_quic_wire_decode_frame_stream(PACKET *pkt,
f->data = PACKET_data(pkt);
- if (!PACKET_forward(pkt, f->len))
+ if (f->len > SIZE_MAX /* sizeof(uint64_t) > sizeof(size_t)? */
+ || !PACKET_forward(pkt, (size_t)f->len))
return 0;
return 1;
@@ -755,10 +759,11 @@ int ossl_quic_wire_decode_frame_conn_close(PACKET *pkt,
|| reason_len > SIZE_MAX)
return 0;
- if (!PACKET_get_bytes(pkt, (const unsigned char **)&f->reason, reason_len))
+ if (!PACKET_get_bytes(pkt, (const unsigned char **)&f->reason,
+ (size_t)reason_len))
return 0;
- f->reason_len = reason_len;
+ f->reason_len = (size_t)reason_len;
return 1;
}
diff --git a/ssl/quic/quic_wire_pkt.c b/ssl/quic/quic_wire_pkt.c
index 484a5cc766..b2bf90e7b6 100644
--- a/ssl/quic/quic_wire_pkt.c
+++ b/ssl/quic/quic_wire_pkt.c
@@ -206,7 +206,7 @@ int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt,
if (!PACKET_copy_bytes(pkt, hdr->dst_conn_id.id, short_conn_id_len))
return 0;
- hdr->dst_conn_id.id_len = short_conn_id_len;
+ hdr->dst_conn_id.id_len = (unsigned char)short_conn_id_len;
/*
* Skip over the PN. If this is a partial decode, the PN length field
@@ -334,7 +334,7 @@ int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt,
if (!PACKET_get_quic_vlint(pkt, &token_len)
|| token_len > SIZE_MAX
- || !PACKET_get_bytes(pkt, &hdr->token, token_len))
+ || !PACKET_get_bytes(pkt, &hdr->token, (size_t)token_len))
return 0;
hdr->token_len = (size_t)token_len;
@@ -642,7 +642,7 @@ int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf,
if (buf_len < QUIC_MIN_VALID_PKT_LEN_CRYPTO + short_conn_id_len)
return 0;
- dst_conn_id->id_len = short_conn_id_len;
+ dst_conn_id->id_len = (unsigned char)short_conn_id_len;
memcpy(dst_conn_id->id, buf + 1, short_conn_id_len);
return 1;
}